?
Solved

SQL Count in Access Module

Posted on 2003-03-16
4
Medium Priority
?
315 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

752 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