Solved

ACCESS DATA SHEET DISPLAY

Posted on 2013-11-13
3
313 Views
Last Modified: 2013-11-13
Hello,
I have an Access 2007 database in which I allow the user to custom build a query. This is done via a series of check boxes. For example: 1) Show all members who are paying by credit card AND the member has not chosen to skip AND the member has not cancelled, etc.

From the information provided by the user in the check box group, I am building a SQL string. The string becomes a query definition and the query is executed. Currently, the user is shown the custom filtered information in a datasheet format.

Here's my question: The user doesn't care about the filtered data (datasheet view). All the user wants/needs to see is the number of members who fit the criteria selected. How is this done?
0
Comment
Question by:waverobber
3 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39646626
He's one way:
DIM rs As Recordset

SET rs = currentDB.OpenRecordset(strSQL)
If rs.EOF Then 
    Me.txtResult = 0
Else
    rs.MoveLast
    Me.txtResult = rs.RecordCount
End If

Open in new window

Ron
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39646631
You can use a Count query, or use DCount.

The Count query would be something like:

Dim s As String
s = "SELECT COUNT(*) AS RecCount FROM YourTable WHERE <Your criteria here>"

Dim dbs As DAO.Recordset
Set rst = Currentdb.Openrecordset(s)

Msgbox "The number of customers is " & rst("RecCount")

DCount would be similar:

Dim i As Integer
i = DCount("IDField", "YourTable", "Your Criteria Here")

Msgbox "The number of customers is " & i

Obviously you'd have to change table and column names to match your own. Also, "Your Criteria Here" would be the same WHERE values you're already using to create your query definition.

Here's more info on DCount:

http://office.microsoft.com/en-us/access-help/dcount-function-HA001228817.aspx
0
 

Author Closing Comment

by:waverobber
ID: 39646689
Works perfect. Thanks...
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now