Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL query syntax problem in VBA

Status
Not open for further replies.

mitch1660

Programmer
Jul 24, 2001
2
CA
This query...
SQLs = "SELECT Nom, DateSam, Job,Di, Lu, Ma, Me, Je,Ve,Sa, Taux_Km FROM Data" & _
&quot; WHERE [Data.DateSam] >=datevalue('&quot; & DateDebut.Value & &quot;') AND [Data.DateSam]<=&quot; & _
&quot;datevalue('&quot; & DateFin.Value & &quot;') AND [Data.Job] =&quot; & Job.Value

... gives me this error:
Too few parameters,1 expected.
Is there somebody to help me to write the good syntax?
 
This article explains where your error is coming from.

To get a more clear error message: add the line

Debug.Print SQLs

after your posted statement, before you set your querydef or whatever else. Run the procedure with the immediate window open (ctl+G), copy the SQL text out of there, and paste it into the SQL view of a new query. Run the new query. It will point you to where the syntax errors are. First fix the SQL in the window, until the query runs; then go back and change your code acccordingly.

Bon courage.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top