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
Solved

ACCESS DATA SHEET DISPLAY

Posted on 2013-11-13
3
319 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

837 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