C
Chris Thorne
I have been having trouble with the error message, "Too
few parameters. Expected:1". I can see that others have
had the same trouble, but I still can't resolve mine. The
code is as follows :
Private Sub Change_Comment_Click()
Dim mydb As Database, myset1 As Recordset, mytempqry As
QueryDef
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set mytempqry = mydb.CreateQueryDef("TEMPQRY", "PARAMETERS
[Forms]![Frm_QStock Quarantine-RCR]![RecNo] Value; " & _
"SELECT [Tbl_QStock Pallets-Quarantine].[Q
Rec], [Tbl_QStock Pallets-Quarantine].[Pallet No] " & _
"FROM [Tbl_QStock Pallets-Quarantine] " & _
"Where ((([Tbl_QStock Pallets-Quarantine].[Q
Rec]) = [Forms]![Frm_QStock Quarantine-RCR]![RecNo])) " & _
"ORDER BY [Tbl_QStock Pallets-Quarantine].
[Pallet No];")
Set myset1 = mytempqry.OpenRecordset(dbOpenForwardOnly)
Do Until myset1.EOF
MsgBox myset1![Pallet No]
myset1.MoveNext
Loop
myset1.Close
mydb.Close
End Sub
The temporary query the code creates works fine if you
open the query. The parameter is based on a field in a
form I have created. If anyone has any suggestions, please
let me know. Cheers!
few parameters. Expected:1". I can see that others have
had the same trouble, but I still can't resolve mine. The
code is as follows :
Private Sub Change_Comment_Click()
Dim mydb As Database, myset1 As Recordset, mytempqry As
QueryDef
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set mytempqry = mydb.CreateQueryDef("TEMPQRY", "PARAMETERS
[Forms]![Frm_QStock Quarantine-RCR]![RecNo] Value; " & _
"SELECT [Tbl_QStock Pallets-Quarantine].[Q
Rec], [Tbl_QStock Pallets-Quarantine].[Pallet No] " & _
"FROM [Tbl_QStock Pallets-Quarantine] " & _
"Where ((([Tbl_QStock Pallets-Quarantine].[Q
Rec]) = [Forms]![Frm_QStock Quarantine-RCR]![RecNo])) " & _
"ORDER BY [Tbl_QStock Pallets-Quarantine].
[Pallet No];")
Set myset1 = mytempqry.OpenRecordset(dbOpenForwardOnly)
Do Until myset1.EOF
MsgBox myset1![Pallet No]
myset1.MoveNext
Loop
myset1.Close
mydb.Close
End Sub
The temporary query the code creates works fine if you
open the query. The parameter is based on a field in a
form I have created. If anyone has any suggestions, please
let me know. Cheers!