Setting a DIM value as the result of a query (1 Viewer)

Locopete99

Registered User.
Local time
Today, 07:16
Joined
Jul 11, 2016
Messages
163
Hi Guys,

I've put this here as I think its more VBA then queries.

I have a load of queries that count the number of instances of where a record was sent to.

For example how many records were sent to department X for processing.

The Sql for this is

Code:
SELECT Count(*) AS Quantity
FROM Tbl_NPPRstats
WHERE (((Tbl_NPPRstats.[Area Sent to])="Japan"));

What I want to do is log all of these into 1 record on another table for exporting to excel for reporting exercises.

I was hoping to this with a record set.

Is there a way to DIM a value which is the result of a query?

for example the query I've given the SQL for above is Qry_NPPRQTYJPN

I know its not as simple, but is there a way to do something like the following:

Code:
Dim Japan as integer


Japan  = Docmd.openquery "QRY_NPPRQTYJPN", acViewNormal

Any help would be appreciated.
 

Ranman256

Well-known member
Local time
Today, 10:16
Joined
Apr 9, 2015
Messages
4,337
queries return RECORDSETS.

but if you want an INTEGER, you should use
Dcount("*","Tbl_NPPRstats","[Area Sent to])='Japan'")
 

Locopete99

Registered User.
Local time
Today, 07:16
Joined
Jul 11, 2016
Messages
163
Thanks Ranman,

Think I was over complicating things. Thats Exactly what I want.
 

Minty

AWF VIP
Local time
Today, 15:16
Joined
Jul 26, 2013
Messages
10,371
Don't forget you could get all the area counts in one query, then use that as the source of an Excel export.

SELECT [Area Sent To], Count(*) AS Quantity
FROM Tbl_NPPRstats
GROUP BY [Area Sent To]
 

Users who are viewing this thread

Top Bottom