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

Form control SQL syntax in recordset 1

Status
Not open for further replies.

Gfunk13

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

Dim dbs As Database, rst As DAO.Recordset
Set dbs = CurrentDb
Set cld = Me!Classified

Set rst = dbs.OpenRecordset("SELECT [classdate],
Sum(quantity) AS Expr1
FROM Classification " _
WHERE ClassDate = Forms!prod_main!text21
GROUP BY ClassDate;

cld.Value = rst("Expr1")
---
If I replace the form control in the WHERE clause with "date()", it returns the sum for today (as expected). I can't find the syntax for the form control. I've tried putting pound signs around it and a number of other variations, but no luck.
 
How are ya Gfunk13 . . .

. . . and this:
Code:
[blue]   Dim dbs As Database, rst As DAO.Recordset, SQL As String
   
   Set dbs = CurrentDb
   cld = Me!Classified
   SQL = "SELECT [classdate], Sum(quantity) As Expr1 " & _
         "FROM Classification " & _
         "WHERE [ClassDate] = #" & Forms!prod_main!text21 & "# " & _
         "GROUP BY ClassDate;"
   Set rst = dbs.OpenRecordset(SQL, dbOpenDynaset)
   
   cld = rst!Expr1
   
   Set rst = Nothing
   Set dbs = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top