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

Can't use Query As Basis for Recordset

Status
Not open for further replies.

tfayer

Technical User
Aug 4, 2002
41
US
When I run code that contains the following line:

Set rs = db.OpenRecordset("Query1", dbOpenDynaset)

I get a Runtime error 3061 - Two few parameters. Expected 2.

Can anyone help? Why cant I use the query?
 
your query is a parameter query... It's looking for two pieces of data...

What I tend to do is build my sql string in code and then pass the string into an openrecordset command...

now i know your saying to yourself that it should work fine because the query refers to a form that is open and has data in the fields that it needs... (well, that's what i said the first time i came across this error, worked for some time tring to correct it)

the only solution i was able to find was to build the sql in code and pass it to the open recordset command...

If you need help doing this, I'd be more then happy to help...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
I have tried inserting the following. Still Asking for 1 Parameter. I have form open and set to a contactID. Still can't get it to work. Any suggestions.

Set rs = db.OpenRecordset("SELECT tblContacts.contactID, FROM tblContacts WHERE (((tblContacts.contactID)=[Forms]![frmContacts]![contactID]));", dbOpenDynaset)
 
ok, change this to:

Set rs = db.OpenRecordset("SELECT tblContacts.contactID, FROM tblContacts WHERE (((tblContacts.contactID)=" & Forms!frmContacts!contactID & "));", dbOpenDynaset)

See if that works:)

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top