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

Error 3061 for DatePart in criteria of recordset 1

Status
Not open for further replies.

Gfunk13

Programmer
Feb 28, 2004
17
US
The following is giving me a syntax error (Error 3061: Too few parameters. Expected 1.)

Set rst = dbs.OpenRecordset("SELECT Sum(Ahrs)+Sum(Bhrs)+
Sum(Chrs) AS Expr2 FROM Production
WHERE (((DatePart('m',[proddate]))=DatePart('m',Forms!PROD_Main!Text21)));")

The problem is in:
=DatePart('m',Forms!PROD_Main!Text21)));")

If I replace it with:
=Month(Now())));")
....it works fine.

Tried several variations without success. Any help is much appreciated.
 
How about:

[tt]Set rst = dbs.OpenRecordset("SELECT Sum(Ahrs)+Sum(Bhrs)+
Sum(Chrs) AS Expr2 FROM Production
WHERE DatePart('m',[proddate])=" & DatePart('m',Forms!PROD_Main!Text21)[/tt]

You could have used Month for these dates, too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top