Solved

ACCESS DATA SHEET DISPLAY

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

911 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

20 Experts available now in Live!

Get 1:1 Help Now