Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

SQL Count in Access Module

Posted on 2003-03-16
4
Medium Priority
?
319 Views
Last Modified: 2012-06-21
I want to perform an SQL Count within an Access VB module and put that value into a variable.

I know how to word the SQL statement

SELECT COUNT(*) FROM tbl

But cannot figure out how to proceed from there in terms of executing this statement.

Its an easy question and I'm hoping someone can help.
0
Comment
Question by:T77DW
3 Comments
 
LVL 1

Expert Comment

by:njelger
ID: 8150114
Dim iCnt As Integer
iCnt = DCount("*", "tbl")

/ j
0
 
LVL 2

Accepted Solution

by:
i014354 earned 200 total points
ID: 8151151
Dim iCnt as Integer
Dim rs as Recordset
Dim strSQL as String

strSQL = "Select Count(*) as RecCnt from tbl"
rs.open strSQL

iCnt = rs!RecCnt

0
 
LVL 2

Expert Comment

by:HobsonT
ID: 8697126
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
RECOMMENDATION: Accept i014354's Comment as Answer
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Trevor
EE Cleanup Volunteer
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question