Combo Box null value

SheaLee

Registered User.
Local time
Today, 03:03
Joined
Dec 22, 2005
Messages
40
not sure if a combo box can contain a null value
I have two combo boxes I want to make sure the user fills in box one before going to box two here what I got so far:
Private Sub ResetTxtBoxes()
If cmbBox1 = Null Then
Me!cmbBox2.Enabled = False
Else
Me!cmbBox2.Enabled = True
End If

End Sub
this is not working
 
I think the combobox can have a null value, but then nothing would be highlighted.

What I would suggest is establishing a default value of "0" (zero) and assigning it to a "No entry" option (or "Please Select an Entry". Then put in code to keep the user from leaving the combo box if the value =0 or is greater than your highest value.
 
Thanks I'll try it
 
Ahh the infamous null issue :mad:

Your code should read as follows

Private Sub ResetTxtBoxes()
If isnull(cmbBox1) Then
Me!cmbBox2.Enabled = False
Else
Me!cmbBox2.Enabled = True
End If
End Sub

The use of the "IsNull" method is the only sure way to catch nulls.
Also note that if the combo box is set to text format, the empty field might be "", in that case use the following

Private Sub ResetTxtBoxes()
If cmbBox1="" Then
Me!cmbBox2.Enabled = False
Else
Me!cmbBox2.Enabled = True
End If
End Sub

Regards
LinData
 

Users who are viewing this thread

Back
Top Bottom