Condition for Combo Box for= Null

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

Guest

i have a Combo Box in my form where default value is "Null". User is
supposed to select a item before going forward. If by chance user misses to
select a item from combo box, i need to restrict the user going forward to
the next field at this level.in other words i want the cusrsor to go back and
setfocus to combobox.

Please help

ron
 
you could use the combobox control's OnExit event, as

If IsNull(Me!ComboBoxName) Then
Cancel = True
MsgBox "Choose a value from the droplist."
End If

this is extremely restrictive, though. once you enter the control, you can't
get out of it if it's Null; and sometimes your user may want to - to cancel
a new record, for instance. the user could enter a value just to get out of
the control, then cancel, or undo, or whatever - but that sort of maneuver
is frustrating to users. i would probably do an "overall" validation at
strategic points in the data entry, such as before saving a record (using
the form's BeforeUpdate event), or perhaps before moving from one "group" of
data entry controls to another.

hth
 
If this combo is bound to a field in your table, open the table in design
view and select the field. In the lower pane, set the Required property to
Yes. This will prevent the user saving the record, even if they never visit
the combo (e.g. by clicking another control later in the tab order).

You could also use the BeforeUpdate event of the form (not the control), and
cancel the event if the combo IsNull(). As Tina explained, you must use
IsNull(), becuase nothing is ever equal to Null. For an explanation of why,
see:
Common errors with Null
at:
http://members.iinet.net.au/~allenbrowne/casu-12.html
 
Back
Top