Subject: too few variables when running sql qry through vba
Posted By: Christaaay Post Date: 12/19/2005 2:09:53 PM
I am attempting to call a query from VBA through a form and receive an error message that there are too few variables.  Can anyone tell me where i've gone wrong in my sql?  i'm trying to pull the last 4 records in my main table (Email_Data) and ensure that the primary key (Count_ID) contains a cycle of numbers i am attempting to assign to each record.  

SELECT TOP 4 tbl_Email_Data.Count_ID, tbl_Email_Data.queue_key
FROM tbl_AssocTbl INNER JOIN tbl_Email_Data ON tbl_AssocTbl.Queue = tbl_Email_Data.queue_key
WHERE (((tbl_AssocTbl.cycled_ind)=True) AND ((tbl_Email_Data.request_type) Not In ("rt14")))
GROUP BY tbl_Email_Data.queue_key
ORDER BY Last(tbl_Email_Data.Count_ID);
Reply By: Bob Bedell Reply Date: 12/19/2005 2:37:18 PM
Your query doesn't have any parameters, so I'd assume "variable" is referring to a variable in your code.

Before running your SQL from code, paste it in the query designer and run it there to see if it flys for you.

But your error message doesn't seem to relate to your SQL per se. How are you executing it in code?

Bob

Reply By: kindler Reply Date: 12/19/2005 3:21:43 PM
Set a breakpoint (F9) in your VBA code at the start of the function then step through it.  Your SQL does not seem to be the problem so it might be something else.


Go to topic 37710

Return to index page 414
Return to index page 413
Return to index page 412
Return to index page 411
Return to index page 410
Return to index page 409
Return to index page 408
Return to index page 407
Return to index page 406
Return to index page 405