Syntax needed for Where clause

Magster

Registered User.
Local time
Today, 04:34
Joined
Jul 30, 2008
Messages
115
I have a combo box on a form where I allow the user to pick an office. The primary key is the bound column which I then want to use in a stored query to limit the query results to the specific office selected. I can easily do this with the docmd.runSQL in the module, but I'd like to use a stored query instead.

My exact problem is I can't get the syntax correct in the Where clause in the query design. I use the build feature and get the following: [Forms]![frmReports]![cboOffice] which doesn't work. If I manually put the key value in the Where clause, it works fine.

If anyone can please tell me the correct syntax for the Where clause I would greatly appreciate your help!

Thank you in advance
 
The syntax looks fine. I'd wonder if the combo returned multiple columns and the bound column wasn't what was expected by the query. Or if you used a lookup field.
 
Thank you - I did have an error in setting up the combo box. I was using a union query that I added another field to and that became the bound column by mistake. I guess I got "wound up" about the syntax because I couldn't specifiy column(0) or column(1) as I thought I should be able to.

That brings up question - Can one specifiy a different column in the query instead of the bound column? Just wondering!

Thanks much for getting me to pull my head out of the sand.
 
Not as easily as you'd think you should be able to. If memory serves, you have to use the Eval() function.
 
Thank you again - I'll have to give that a try.
 

Users who are viewing this thread

Back
Top Bottom