Keep a Combo Box from opening

A

Alex

When a user clicks on FieldTwo, which is a combobox, is there a way for a
msgbox to appear saying that FieldOne needs to be populated before FieldTwo
is changed? Thanks.
 
J

jmonty

Use the Enabled property.
Right-click on the combobox and select Properties. Click on the Data tab.
Set the Enabled property to NO to prevent any editing. Save.

Next open the Properties for the first field. Click on the Events tab.
Click just to the right of the the OnChange event (a button will appear).
Select Code Builder. Enter the code to test to see if there is a value in the
first field

Private Sub Text0_Change()
If Nz(Me.Text0, "") <> "" Then
Me.Combo2.Enabled = True
Else
Me.Combo2.Enabled = False
End If
End Sub

If it is an acceptable value then set the combo boxes Enabled property to Yes.

jmonty
 
M

Marshall Barton

Alex said:
When a user clicks on FieldTwo, which is a combobox, is there a way for a
msgbox to appear saying that FieldOne needs to be populated before FieldTwo
is changed?

Instead of that, why not disable the combo box until
FieldOne has an acceptable value? This can be done by using
the FieldOne's AfterUpdate even and the form's Current to
check FieldOne's value and enable/disable FieldTwo. If any
non-Null value is acceptable, the code in both events would
be:

Me.FieldTwo.Enabled = Nor IsNull(Me.FieldOne)
 
F

fredg

Instead of that, why not disable the combo box until
FieldOne has an acceptable value? This can be done by using
the FieldOne's AfterUpdate even and the form's Current to
check FieldOne's value and enable/disable FieldTwo. If any
non-Null value is acceptable, the code in both events would
be:

Me.FieldTwo.Enabled = Nor IsNull(Me.FieldOne)

Marsh,

"Nor" surely Not. <g>
Me.FieldTwo.Enabled = Not IsNull(Me.FieldOne)
 
Top