Access - Subforms - Diabling fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

diHi,

I am a new user to Access and I am trying to do the following. I have a
form called Meetings and a subform called Attendants. On the form load I
want some of the fields from the form and some from the subform disabled.
Unfortunately, I am able to get the filed associated with the form disabled
by writing some code on the Form Load event. I tried several ways to disable
the fields associated with the subform: 1. Tried writing code in the Form
Load event, but it wouldn't recognize the subform fields there. 2. Tried
writing code on the subform load event, but got an error stating "You can't
siable a control while it has the focus". Any help you can provide here
would be greatly helpful. Thanks in advance.
 
NewUserToAccess said:
diHi,

I am a new user to Access and I am trying to do the following. I
have a form called Meetings and a subform called Attendants. On the
form load I want some of the fields from the form and some from the
subform disabled. Unfortunately, I am able to get the filed
associated with the form disabled by writing some code on the Form
Load event. I tried several ways to disable the fields associated
with the subform: 1. Tried writing code in the Form Load event, but
it wouldn't recognize the subform fields there. 2. Tried writing
code on the subform load event, but got an error stating "You can't
siable a control while it has the focus". Any help you can provide
here would be greatly helpful. Thanks in advance.

You should be able to disable the subform controls in the main form's
Load event if you use the correct syntax:

Me!NameOfSubformControl.Form!NameOfControl.Enabled = False

Note that "NameOfSubformControl" must be the name of the control on the
main form that holds the subform, which may or may not be the name of
the form object that is serving as the subform.

However, as the second error message says, "You can't disable a control
while it has the focus". That means that, if the subform's current
active control is the one you want to disable, you have to move the
subform's focus to a different control first. You mayhave to do this:

With Me!NameOfSubformControl.Form
!SomeOtherControl.SetFocus
!ControlToBeDisabled.Enabled = False
End With
 
Back
Top