Re V.T.Dinh SQL reply

M

Mark Taimanov

Apologies for starting another thread naming you in the
message but I wasn't sure if you would go back to the
original thread "Syntax re MultiSelect List Box"

In your reply - and my thanks for it ! - you wrote :

"Why not resolve the reference to the Control when you
construct the SQL String?

Try:

Q.SQL = "SELECT * FROM [DMA Photo Library] " & _
" WHERE [subCategoryName] In (" & Criteria & _
") AND [Category] = " & Me!cboCategories

(assuming the Category Field / bound Column of the
ComboBox is numeric)."

This almost works but there is a syntax error re missing
operator(s). And the Category field of the bound column is
text.

Thank you again.

Mark
 
V

Van T. Dinh

You need to enclose literal Text / String in double-quotes
Chr$(34). SingleQuotes OK also.

Try:

Q.SQL = "SELECT * FROM [DMA Photo Library] " & _
" WHERE [subCategoryName] In (" & Criteria & _
") AND [Category] = " & Chr$(34) & _
Me!cboCategories & Chr$(34)

HTH
Van T. Dinh
MVP (Access)

P.S. Most regular respondents watch threads they replied
to for 1 or 2 weeks at least so no problem continuing the
thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top