Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

saving query counts to a variable

Status
Not open for further replies.

DSaba10

Programmer
Nov 15, 2007
35
US
Let's say I've got a table, and I want to pull a count of a specific value for one specific field... like anyone who lives in CA, and then save that as a variable for later use, how would I accomplish this? I've been told I could do an actual query, then save the results as a separate table, then get a count of that, but that just seems like it would waste system resources and create useless tables. I unfortunately don't have the help files installed on my work PC here, so I'm unable to consult them. Thanks in advance for any help you might be able to provide.

-Doug
 
oh well... answered my own question by some more research and messing around.

count for <field name> <operator> <condition> to <variable>
 
or

Code:
Select Count(*) From ... where <field name> <operator> <condition> Into Array laCount

laCount(1) is your count or simply laCount, as you can adress the first element of an array as if it was a simple variable.

This has the advantage over COUNT ... TO, that it also works for more than one table and complexer sql.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top