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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too few Parameters Expected Error 2

Status
Not open for further replies.

vix666

IS-IT--Management
Jul 17, 2003
63
AU
I have an error which appears when i run my code, i have had a look at it and i dont know whats wrong, so any help would be gladly appreciated

Many Thanks

Vicky

strSQL = "SELECT Count([Complaints Table].Counter) AS CountOfCounter, [Complaints Table].[Type of Complaint], Format([Date],""mm"")) AS Month " & _
" FROM [Complaints Table]" & _
" WHERE ((([Complaints Table].Date) Between '#[Forms]![Print Request between dates]![sdate]#'" & _
" And '#[Forms]![Print Request between dates]![edate]#')" & _
" AND (([Complaints Table].[Attributable to Company])=""epco""))" & _
" GROUP BY [Complaints Table].[Type of Complaint], Format([Date],""mm""))" & _
" ORDER BY [Complaints Table].[Type of Complaint], Month;"
 
Hi Vicky!

Try this:

strSQL = "SELECT Count([Complaints Table].Counter) AS CountOfCounter, [Complaints Table].[Type of Complaint], Format([Date],""mm"")) AS Month " & _
" FROM [Complaints Table]" & _
" WHERE ((([Complaints Table].Date) Between #" & [Forms]![Print Request between dates]![sdate] & "#" & _
" And #" & [Forms]![Print Request between dates]![edate] & "#)" & _
" AND (([Complaints Table].[Attributable to Company])=""epco""))" & _
" GROUP BY [Complaints Table].[Type of Complaint], Format([Date],""mm""))" & _
" ORDER BY [Complaints Table].[Type of Complaint], Month;"

hth


Jeff Bridgham
bridgham@purdue.edu
 
Hi vicky,

sorry to find out you did not solve your problem. When you add # you have to loose the '.

I think this will work. Post back if it doesn't

strSql = "SELECT Count([Complaints Table].Counter) AS CountOfCounter," & _
[Complaints Table].[Type of Complaint]," & _
Format([Date],""mm"") AS Month " & _
" FROM [Complaints Table]" & _
" WHERE [Complaints Table].Date Between #[Forms]![Print Request between dates]![sdate]#" & _
" And #[Forms]![Print Request between dates]![edate]#)" & _
" AND [Complaints Table].[Attributable to Company] = ""epco"" " & _
" GROUP BY [Complaints Table].[Type of Complaint], Format([Date],""mm"")" & _
" ORDER BY [Complaints Table].[Type of Complaint], Month"



regards,
nicsin
 
Thanks for the help. I tried both bits of code, the last one solves the too few parameters error but then i get another error on the bit below, saying "syntax error in date in query expression"

WHERE [Complaints Table].Date Between #[Forms]![Print Request between dates]![sdate]#" & _
" And #[Forms]![Print Request between dates]![edate]#)" &

Any other ideas?

Thanks for all your help

Vicky
 
oops... delete the parenthesis after [edate]# and it will work.
 
nope doesnt work :(

Any other suggestions?

Thanks

Vicky
 
What is the Date inside the format function? As far as I know Date is a reserved keyword which cannot be used. you should rename it and try this:

strSql = "SELECT Count([Complaints Table].Counter) AS CountOfCounter," & _
" [Complaints Table].[Type of Complaint]," & _
" Format([Date],""mm"") AS Month " & _
" FROM [Complaints Table]" & _
" WHERE [Complaints Table].Date Between #" & [Forms]![Print Request between dates]![sdate] & "#" & _
" And #" & [Forms]![Print Request between dates]![edate] & "#" & _
" AND [Complaints Table].[Attributable to Company] = ""epco"" " & _
" GROUP BY [Complaints Table].[Type of Complaint], Format([Date],""mm"")" & _
" ORDER BY [Complaints Table].[Type of Complaint], Month"

 
Hi Vicky!

Let's try again:

strSQL = "SELECT Count([Complaints Table].Counter) AS CountOfCounter, [Complaints Table].[Type of Complaint], Format([Date],""mm"") AS Month " & _
" FROM [Complaints Table]" & _
" WHERE [Complaints Table].Date) Between #" & [Forms]![Print Request between dates]![sdate] & "#" & _
" And #" & [Forms]![Print Request between dates]![edate] & "#" & _
" AND [Complaints Table].[Attributable to Company]=""epco""" & _
" GROUP BY [Complaints Table].[Type of Complaint], Format([Date],""mm"")" & _
" ORDER BY [Complaints Table].[Type of Complaint], Format([Date],""mm"");"

See if this works!




Jeff Bridgham
bridgham@purdue.edu
 
Thanks alot for that, this sql has been bugging me for ages :) Thankyou both for all your help so a star for you both.

Thanks Again

Vicky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top