Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2005

Tip: Looking for answers? Try searching our database.

Enable/disable controls in subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian - 13 Dec 2005 01:47 GMT
I am getting a non-specified runtime error on Access 2003 runtime only (can't
duplicate on my development station) under this circumstance:

In my Form_Current, I call a sub that enables/disables certain controls
based on contents of other controls. Some of the controls that I
enable/disable are on a subform.

It fails on the second line below (ProductID1 is a control on the form,
TripDetail is the name of the subform, and BundlesProduct1 is a control on
the subform):

If IsNull(ProductID1) Then
   Me.TripDetail!BundlesProduct1.Enabled = False
Else
   Me.TripDetail!BundlesProduct1.Enabled = True
End If

The code runs fine when I open the form, but not after going to a new record.
Allen Browne - 13 Dec 2005 02:38 GMT
Suggestions:

1. Include the .Form bit:
   Me.TripDetail.Form!BundlesProduct1.Enabled = False
Especially with A2003, that helps.

2. If BundlesProduct1 happens to be the ActiveControl of TripDetail.Form,
the attempt to disable it could fail.

3. If the subform has no records (probably the case if the main form is at a
new record), AND no new records can be added, the detail section of the
subform goes completely blank. Referring to the non-existent control in the
subform then generates an error.

Example of when the subform could not add new records:
- Its AllowAdditions property is No.
- The subform is based on a non-updatable query.
- The user does not have permissions to add records.
- The main form was opened with AllowEdits as No, so it does not allow
changes in the subform either.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I am getting a non-specified runtime error on Access 2003 runtime only
>(can't
[quoted text clipped - 16 lines]
> The code runs fine when I open the form, but not after going to a new
> record.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.