INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

combo box value trouble

combo box value trouble

(OP)
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.

RE: combo box value trouble

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

RE: combo box value trouble

(OP)
Thank you so much missinglinq, i appreciate the help. I got it to work ...

RE: combo box value trouble

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close