Referring to a control on a form in a SQL SELECT string

J

JimP

The following statement is generating a 3061 error - too few parameters. How
do I refer to a control on a form? e.g.

strSQL="SELECT OrderID from Orders WHERE OrderID = Forms!Form1!OrderSel;"
 
F

fredg

The following statement is generating a 3061 error - too few parameters. How
do I refer to a control on a form? e.g.

strSQL="SELECT OrderID from Orders WHERE OrderID = Forms!Form1!OrderSel;"

If OrderID is a Number datatype field, then:
strSQL="SELECT OrderID from Orders WHERE OrderID = " &
Forms!Form1!OrderSel

If OrderID is a Text datatype field, use:
strSQL="SELECT OrderID from Orders WHERE OrderID = '" &
Forms!Form1!OrderSel & "'"
 

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