PC Review


Reply
Thread Tools Rate Thread

Call parameter query in Access from Excel VBA?

 
 
Gustaf
Guest
Posts: n/a
 
      25th Apr 2008
I've prepared a query in Access that calculates a number that I want to display in Excel, using VBA and ADO. Here's the query in Access:

PARAMETERS [p_month] DateTime;
SELECT Count(*) AS [Number]
FROM (SELECT DISTINCT Occupancy.PersonID
FROM Occupancy WHERE (((Occupancy.Month)=[p_month]))
) AS [Table];

So, the query accepts a parameter and returns a value. Because it's just a value, I figure I won't need to construct a recordset object. All examples I've seen so far returns a recordset, but I hope to make this simple and fast. How would you call this query from VBA and how do you extract the return value?

Gustaf
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      25th Apr 2008
Not that familiar with Acess, but most likely you could do this be adding an
"out" parameter to your procedure.

http://groups.google.com/group/micro...4f98c5257ffa54

Tim


"Gustaf" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I've prepared a query in Access that calculates a number that I want to
> display in Excel, using VBA and ADO. Here's the query in Access:
>
> PARAMETERS [p_month] DateTime;
> SELECT Count(*) AS [Number]
> FROM (SELECT DISTINCT Occupancy.PersonID
> FROM Occupancy WHERE (((Occupancy.Month)=[p_month]))
> ) AS [Table];
>
> So, the query accepts a parameter and returns a value. Because it's just a
> value, I figure I won't need to construct a recordset object. All examples
> I've seen so far returns a recordset, but I hope to make this simple and
> fast. How would you call this query from VBA and how do you extract the
> return value?
>
> Gustaf



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Access Query From Excel With Parameter? EricG Microsoft Access VBA Modules 3 12th Nov 2009 03:44 PM
Open Access query from Excel using parameter Dan Microsoft Excel Programming 3 26th Jun 2009 06:02 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Microsoft Access Queries 1 13th Dec 2004 07:54 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Microsoft Access Reports 1 13th Dec 2004 07:54 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Microsoft Excel Misc 1 13th Dec 2004 07:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:06 PM.