Runtime 3061

Acropolis

Registered User.
Local time
Today, 06:33
Joined
Feb 18, 2013
Messages
182
HI


I have the below in a load of code


Code:
Dim db as DAO.Database
Dim rsEmail as DAO.Recordset


set db= CurrentDB


            Set rsEmail = db.OpenRecordset("SELECT tblfieldresource.fullname, tblfieldresource.email FROM tblfieldresource WHERE (((tblfieldresource.FieldResourceID) IN (SELECT tblfieldworks_attendedjobs.FieldResourceID FROM tblfieldworks_attendedjobs WHERE (((tblfieldworks_attendedjobs.FieldWorksID)=[TempVars]![tmpFieldWorksID])))))")


When I run it, I get the error message RunTIme Error 3061. Too Few Parameters. Expected 1.


The FE is connected to a MySQL backend, if I run the above in a SqlYog it works fine and returns what it should, if I create a qry in Access and run it, it work fine and returns what it should, but when in the code it doesn't.


Any idea's?
 
RecordSet objects don't like parameters unless they are defined via a QueryDef object first.

If you search the form for 'Too Few Parameters: Expected' then you will find countless examples of this and how to solve it.

Effectively the '[TempVars]![tmpFieldWorksID]' needs defined in the Query. The examples will show you how.
 
Sussed it.

Very simple in the, just missed a couple of small characters from the line,

Code:
WHERE (((tblfieldworks_attendedjobs.FieldWorksID)=[TempVars]![tmpFieldWorksID])))))")
changed to

Code:
WHERE (((tblfieldworks_attendedjobs.FieldWorksID)= [COLOR=red][B]" &[/B][/COLOR] [TempVars]![tmpFieldWorksID][COLOR=red] [B]& "[/B] [/COLOR])))))")
Works a treat now with that added in.
 

Users who are viewing this thread

Back
Top Bottom