Combo boxes and disabled fields

  • Thread starter Thread starter Stuart
  • Start date Start date
S

Stuart

This will probably be a simple solution, but I'm fairly
new to Access. I am starting to design a form and would
like to know if it is possible to enable a field depending
on selection from a combo box. EG. If you select the
item "sold" from the combo box, can you enable the "date"
field ONLY for that selection?
 
Sure. In the combo box AfterUpdate event,

If <your combo box name> = "Sold" Then
<your date field name>.Enabled = True
End If

then use the Form AfterUpdate event to turn it back off

<your date field name>.Enabled = False

The word Date is an Access reserved word. To avoid
unexpected behavior, be sure your field is named something
else, like StatusDate, e.g.

You can get a list of reserved words through a Google
search on "Access Reserved Words".

HTH
Kevin Sprinkel
 
Yes definitely. In the AfterUpdate() code for the combo box you can adjust
the Enabled property of whatever control you like.

Private Sub cboYourCombo_AfterUpdate()

If cboYourCombo = "WHATEVER" Then

OtherControl.Enabled = False/True

End If

or you could use a Select statement to evaluate the combo box:

Private Sub cboYourCombo_AfterUpdate()

Dim Info As String

Info = cboYourCombo

Select Case Info

Case "Value1"

OtherControl.Enabled = False/True
Exit Sub

Case "Value2"

OtherControl2.Enabled = False/True
Exit Sub

End Select

HTH,

T.
 
Back
Top