SteveL13
asked on
Trying to force an answer in a combobox
I have this code in the afterupdate event of a combobox. But the field lets be go on to the next field without forcing an entry in the combobox.
What am I doing wrong? (it is a text field if that matters)
My code:
What am I doing wrong? (it is a text field if that matters)
My code:
If IsNull(cboDCAORD) Then
MsgBox "You must select either Accept or Deny in this field."
Me.cboDCAORD.SetFocus
Exit Sub
End If
You could add or if cboDCAORD = "". However, getting them stuck in that field could be frustrating. An alternative approach that I've used is to set the field red to denote error and not let them get off the page at the end if any fields are marked as not validated.
ASKER
I actually want them to get stuck on the field. I added your suggestion and they get the message but the focus does not stay on the combobox.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dale and Rey... I've tried both suggestions. But now if the user decides to delete the record after data has been entered, they get the message even though they don't even want the record any longer.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or simply press the Esc key once (for the current control) or twice for the entire record. I generally prefer the cancel button though.