Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ACCESS DATA SHEET DISPLAY

Posted on 2013-11-13
3
Medium Priority
?
324 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
[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
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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

722 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