Form / Subform

T

Terry Maccarone

I have a form with a subform.
I have a combo box that shows a list of employee names when you click on the
arrow. I have 6 fields on the main form. On one field I set the enabled
property to "No". I want this field to enable after you click on an
employee name. When I use the following: ExtraWeek.enabled for an event
procedure, I always get a run time error.

Thanks for your assistance.
 
T

Terry Maccarone

Hi Steve,
ExtraWeek is the name of a yes/no field!
As far as what event - I clicked on the combo box field and used "On Change"
and started an event procedure.

Thanks for your help
 
S

Steve Schapel

Terry

I would suggest you use the After Update event of the combobox. Forms
don't have fields. If you have a checkbox on the form, which is bound
to the ExtraWeek field in the table, the checkbox control may or may not
be named ExtraWeek, so you need to check that (no pun intended). The
Enabled property refers to the control, so you have to use the name of
the control. So, try it along these lines...

Private Sub YourCombobox_AfterUpdate()
Me.YourCheckboxName.Enabled = True
End Sub

If it's possible for the user to delete the entry in the combobox so it
is blank again, and you then want the checkbox to not be enabled again,
you might do it like this...

Private Sub YourCombobox_AfterUpdate()
Me.YourCheckboxName.Enabled = Not IsNull(Me.YourCombobox)
End Sub
 
T

Terry Maccarone

Thanks Steve! It worked perfect. I have another question regarding my
subform on the same form....
In regular view, the subform shows as a datasheet. On the subform I sent all
the fields to disabled to protect the fields before a name is chosen in the
combo box. I want them disabled after the user selects a name. How should I
code this?

Thanks!
 
S

Steve Schapel

Terry,

Rather than trying to manage all the individual controls on the subform,
maybe it would serve your purposes to disable/enable the subform control
itself? In this case, the code would be similar to what I gave before,
like this...

Private Sub YourCombobox_AfterUpdate()
Me.YourCheckboxName.Enabled = True
Me.YourSubformName.Enabled = True
End Sub

or...
Private Sub YourCombobox_AfterUpdate()
Me.YourCheckboxName.Enabled = Not IsNull(Me.YourCombobox)
Me.YourSubformName.Enabled = Not IsNull(Me.YourCombobox)
End Sub
 
Top