Question Combo box filter error in code question.

mjanalyst

Registered User.
Local time
Today, 14:30
Joined
Jul 24, 2012
Messages
19
Hello,

I am still new at access and I am using a combo box to filter a 2nd form upon clicking a button. I posted on this topic the other month and was given some code that works. I am attempting to tweak it for another part of my database.

I am receiving a Run-time error "3464':

Data type mismatch in criteria expression.

The code I am using is listed below.
Please could you help me figure out what I am doing wrong. Thanks.

DoCmd.OpenForm "Utilities Contacts", , , "[Utility] = """ & Me.Utility.Column(1) & """"
DoCmd.Close acForm, "Utility Menu"
 
Can you tell us:

What kind of data field is "Utility"? (Text or Number)
What kind of data is in Me.Utility.Column(1)
What kind of data is in Me.Utility.Column(0)
 
Bob,

Thanks for the response. Utility data field is text. It is a list of utility companies you can choose from.

I am not sure the answers to you 2nd and 3rd question cause I was given the code before and not sure what it references and I don't know what the 0 or 1 means. The original code that works that I was give is this:

DoCmd.OpenForm "Paperwork", , , "[ESCO Name] = """ & Me.Combo19.Column(1) & """"
DoCmd.Close acForm, "ESCO Menu"

If you could direct me to how I can find the answers to your other questions I will do so. Thanks.
 
OK. In Me.Utility.Column(1)
"Me." is the current form
"Utility." is the name of a control on that form. List boxes and combo boxes can have often have more than one column of data. Very often, they have one or more columns "hidden". For example, a combo box that lists Products may have its first column hidden and the second column visible. First column would contain the products Unique ID, normally a "AutoNumber" and the second column would show the name of the product. These columns are numbered from left to right. The first column is Column(0), the second is Column(1) etc. So, in your code, you are saying, find the data in the "Utility" field that is tha same as the second column of the list/combo box.
Maybe you need :
Me.Utility.Column(0)

This is why I was asking about Column(0) and Column(1)
 
Bob,

Thanks for the explanation. That makes a lot of sense. So after your lesson I went through and checked the data field types and the combo box columns. I did a little testing and it works now. Thank you so much for your help. Cheers.

Mike
 

Users who are viewing this thread

Back
Top Bottom