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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box value trouble 1

Status
Not open for further replies.

DBServices

Programmer
Aug 19, 2010
54
US
I have a problem I can't figure out. I have a couple unbound combo boxes (cboEmployeeName and cboCustomerName) on an unbound form along with other controls as well. There are numerous controls on the form for user to select and once all are selected, I have a submit button that will run a SQL statement and Insert Into a table all the values. All works fine, but before I run the SQL statement I check to make sure all controls are selected and have values before sql statement runs. When I check to make sure the customer and employee have been selected in the combo boxes, it runs even if there is no selection.
My code is:
If Me.cboEmployeeName.Value = Null Then
MsgBox ("You must select an employee"), vbOKOnly, "NO EMPLOYEE SELECTED"
Me.Undo
Me.cboEmployeeName.SetFocus
Exit Sub
End If
I've tried using cboEmployeeName.value = false
and cboEmployeeName.value = ""
and that doesn't work either.
How can I make sure there is a selection in the combo box?
Any help is GREATLY appreciated!! Thanks, Dannie.
 
You can't use

If Me.cboEmployeeName.Value = Null Then

The correct VBA code for this kind of thing would be

If IsNull(Me.cboEmployeeName) Then

or, if there a possibility of a Zero-Length String (unlikely, I would think, in a Combobox, then

If Nz(Me.cboEmployeeName, "") = "" Then


Hope this helps!

There's always more than one way to skin a cat!

All posts/responses based on Access 2003/2007
 
Thank you so much missinglinq, i appreciate the help. I got it to work ...
 
Glad we could help!

Good luck with your project!

Hope this helps!

There's always more than one way to skin a cat!

All posts/responses based on Access 2003/2007
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top