"Too few parameters"

gdanalakshmi

Registered User.
Local time
Today, 01:54
Joined
Nov 26, 2002
Messages
102
Dim CurDB As DAO.Database
Dim MoveWorksheetTB As DAO.Recordset

Set CurDB = CurrentDb()


sqlQry = "SELECT * FROM MoveWorksheets WHERE MoveRequest_ID = [Forms]![EditMoveInfo]![MoveRequest_ID]"

Set MoveWorksheetTB = CurDB.OpenRecordset(sqlQry)

With MoveWorksheetTB
.MoveFirst
While Not MoveWorksheetTB.EOF = True

[Forms]![EditMoveInfo]![ID1] = !ID

DoCmd.OpenQuery "update test voice"
Wend
.MoveNext
End With

CurDB.Close


When I run the above code, I get a error on
Set MoveWorksheetTB = CurDB.OpenRecordset(sqlQry) line "Too few parameters"

How do i fix this???
 
Try:

sqlQry = "SELECT * FROM MoveWorksheets WHERE MoveRequest_ID=" & [Forms]![EditMoveInfo]![MoveRequest_ID] & ";"
 
I encountered this problem before

Try this:

sqlQry = "SELECT * FROM MoveWorksheets WHERE MoveRequest_ID='" & [Forms]![EditMoveInfo]![MoveRequest_ID] & "';"

notes : add symbol (') before ...WHERE MoveRequest_ID= and before ;

Hope can help you.
 
You need to use the single quotes if the ID is a string. I was assuming that it was a number and therefore you don't want to include the single quotes.

If whatever was going to be there was a date then you need to surround it with # signs.
 
The following piece of code shows how to execute parameter queries from code using DAO.

Code:
Dim dbs As DAO.Database 
Dim rst As DAO.Recordset 
Dim qd As DAO.QueryDef
Set dbs = CurrentDb
Set qd = dbs.QueryDefs!qryQCMainSizeCheck
qd.Parameters![YourParm1] = "SomeValue"
qd.Parameters![YourParm2] = "SomeValue"
Set rst = qd.OpenRecordset
 

Users who are viewing this thread

Back
Top Bottom