Recordset and Queries

  • Thread starter Thread starter Lathwella
  • Start date Start date
L

Lathwella

Guest
HELP!!.
I am trying to build a record set from a query. The query has a criteria set in it refering to a field in another form. Everytime I run the code as follows:
"Set rosrecs = CurrentDb.OpenRecordset("SNGquery", dbOpenDynaset)". I get the following error message.
Run Time error 3061
To few Parameters. Expected 1.
If I remove the criteria the code works Ok.
I am using Access 97.
 
You will receive this error message if you do not explicitly set the value of the parameter query when using VBA

an example would be

dim db as database
dim qryDef as querydef
dim rst as recordset

set db = currentdb
set qrydef = db.querydefs.("MyQry")

' sets parameter to current value on form
qrydef![forms!formname!controlname] = forms![formname]![controlname]

'open recordset
set rst = qrydef.openrecordset()


Hope this helps
John
 

Users who are viewing this thread

Back
Top Bottom