Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2005, 03:09 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default too few variables when running sql qry through vba

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);
 
Old December 19th, 2005, 03:37 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

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

 
Old December 19th, 2005, 04:21 PM
Friend of Wrox
 
Join Date: Dec 2005
Location: , , .
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Running stored procedure in Access VBA Bryon Burbage Access VBA 0 July 21st, 2006 09:14 AM
Running VBA Code from a DataAccessPage BastiMK Access 2 June 1st, 2006 10:10 AM
Running Excel VBA Macros shattered Visual Basic 2005 Basics 0 November 14th, 2005 06:07 AM
Running an SQL query in VBA... Augusta Access VBA 3 December 1st, 2004 05:17 AM
Prb: COUNT qry result NOT SAME as SELECT qry savoym SQL Language 5 July 2nd, 2003 04:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.