Keep a Combo Box from opening

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

Guest

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.
 
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
 
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)
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top