Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access form combo box validation 1

Status
Not open for further replies.

bmoremu

Programmer
Dec 22, 2003
38
US
I have a form with a combo box. When a command button is hit, the value of this combo box is displayed on a label. I've placed the following error-check in the code for the command button click to make sure a value is selected in the combo box.

Code:
If cmbJob.Value = Null Then
    MsgBox "No job selected.", vbCritical
    End
End If

When nothing is selected in the combo box though the error checking doesn't work! Even in debug I mouse over cmbJob.Value and it equals Null yet it skips the If statement! What gives???
 
Hi!

To check for nulls, try:

[tt]If IsNull(cmbJob.Value) Then[/tt]

or
[tt]If len(cmbJob.Value & vbNullString)=0 Then[/tt]

Have a look at TonyJollans faq on "Nulls and Other Nothings - An Explanation" faq707-3710

Roy-Vidar
 
Have you tried this ?
If cmbJob.ListIndex = -1

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top