473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Table showing number or records in each report for each day

6
I'm using access 2010
I need a table that will show the report name, number of records and the date processed. Some of the reports are daily, weekly, monthly, quarterly, etc.

I can add a field to the report to obtain the number of records using count(field).
How do I populate the table for each report...there are at least 15 reports a day and some do may not have records every day.

Will use a date range on my switchboard to obtain monthly,quarterly cross tab reports.

Greatly appreciate any responses....
Aug 16 '16 #1

✓ answered by jforbes

First I would make a method to log the execution of the Report. Something like this would insert a record into the ReportHistory table whenever it is called:
Expand|Select|Wrap|Line Numbers
  1. Public Sub logReportExecution(ByRef sReportName As String, ByRef dRunDate As Date, ByRef lRecordCount As Long)
  2.  
  3.     Dim sSQL As String
  4.  
  5.     sSQL = ""
  6.     sSQL = sSQL & "INSERT INTO ReportHistory ("
  7.     sSQL = sSQL & "  ReportName "
  8.     sSQL = sSQL & ", RunDate "
  9.     sSQL = sSQL & ", RecordCount "
  10.     sSQL = sSQL & ") VALUES ( "
  11.     sSQL = sSQL & "  '" & sReportName & "' "
  12.     sSQL = sSQL & ", #" & dRunDate & "# "
  13.     sSQL = sSQL & ", " & lRecordCount & " "
  14.     sSQL = sSQL & ") "
  15.  
  16.     CurrentDb.Execute(sSQL)
  17.  
  18. End Sub
Then wherever you a running a Report, you can call it like this:
Expand|Select|Wrap|Line Numbers
  1. call logReportExecution("test", now(), 33)
So then, if you call your Report with a Filter, you can do something like this (there are probably some typos):
Expand|Select|Wrap|Line Numbers
  1.     Dim sWhere As String
  2.  
  3.     sWhere = "Thingies>100"
  4.  
  5.     DoCmd.OpenReport "SomeReport", acViewNormal, , sWhere 
  6.     Call logReportExecution("SomeReport", now(), DCOUNT("ID", "SomeReportBaseTable", sWhere ))
  7.  
You could also call the logReportExecution() from within your Report after you have your Record Count.

3 1012
jforbes
1,107 Expert 1GB
First I would make a method to log the execution of the Report. Something like this would insert a record into the ReportHistory table whenever it is called:
Expand|Select|Wrap|Line Numbers
  1. Public Sub logReportExecution(ByRef sReportName As String, ByRef dRunDate As Date, ByRef lRecordCount As Long)
  2.  
  3.     Dim sSQL As String
  4.  
  5.     sSQL = ""
  6.     sSQL = sSQL & "INSERT INTO ReportHistory ("
  7.     sSQL = sSQL & "  ReportName "
  8.     sSQL = sSQL & ", RunDate "
  9.     sSQL = sSQL & ", RecordCount "
  10.     sSQL = sSQL & ") VALUES ( "
  11.     sSQL = sSQL & "  '" & sReportName & "' "
  12.     sSQL = sSQL & ", #" & dRunDate & "# "
  13.     sSQL = sSQL & ", " & lRecordCount & " "
  14.     sSQL = sSQL & ") "
  15.  
  16.     CurrentDb.Execute(sSQL)
  17.  
  18. End Sub
Then wherever you a running a Report, you can call it like this:
Expand|Select|Wrap|Line Numbers
  1. call logReportExecution("test", now(), 33)
So then, if you call your Report with a Filter, you can do something like this (there are probably some typos):
Expand|Select|Wrap|Line Numbers
  1.     Dim sWhere As String
  2.  
  3.     sWhere = "Thingies>100"
  4.  
  5.     DoCmd.OpenReport "SomeReport", acViewNormal, , sWhere 
  6.     Call logReportExecution("SomeReport", now(), DCOUNT("ID", "SomeReportBaseTable", sWhere ))
  7.  
You could also call the logReportExecution() from within your Report after you have your Record Count.
Aug 16 '16 #2
ADezii
8,834 Expert 8TB
  1. My approach was very similar to jforbe's one.
  2. Create a Table named tblReportLog:
    1. [RName]-{STRING}
    2. [Records]-{LONG}
    3. [Processed]-{DATE/TIME}
  3. Copy-N-Paste the following Sub-Routine into a Standard Code Module:
    Expand|Select|Wrap|Line Numbers
    1. Public Sub LogReportInfo(strReportName As String, lngNumOfRecs As Long, dtePDate As Date)
    2.   CurrentDb.Execute "INSERT INTO tblReportLog ([RName],[Records],[Processed]) VALUES ('" & _
    3.                      strReportName & "'," & lngNumOfRecs & ",#" & dtePDate & "#)", dbFailOnError
    4. End Sub
  4. For every Report you wish to Log, Copy-N-Paste the following Code into the Close() Event of the Report:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Report_Close()
    2.   Call LogReportInfo(Me.Name, DCount("*", Me.RecordSource), Now())
    3. End Sub
  5. Sample OUTPUT using three Reports from the Sample Northwind Database:
Expand|Select|Wrap|Line Numbers
  1. PK    RName                    Records    Processed
  2. 1     Customer Address Book    29        8/17/2016 11:53:01 AM
  3. 2     Top Ten Biggest Orders   10        8/17/2016 11:54:44 AM
  4. 3     Customer Phone Book      29        8/17/2016 11:54:50 AM
  5.  
P.S. - The Code is based on Reports requiring no Parameters.
Aug 17 '16 #3
Cbold
6
Thanks for the replies. I actually used something very similar to ADezii
I'm now working thru the reports that don't have any records and dealing with sub reports.
Aug 18 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Amy | last post by:
I'm trying to add an autoincrementing id to a table based on an existing field Name, but Name has duplicated records. How can I do that in ACCESS? Thanks. Amy
5
by: Terri | last post by:
I have a form with a multi-select combo. I dynamically build a SELECT statement, open a report, and set the recordsource to my dynamic SELECT statement. I count the records returned in the report...
3
by: Peter | last post by:
Dear all, Would you tell me how to solve the following two problems in an access file upon preparing report form: a) I have written an IIf function for a string field at the beginning of...
1
by: Rinee | last post by:
Hi, I have a database of a bunch of contractors who have signed a safety agreement with us, their contact info, their insurance info, etc. Each was assigned an ID number as the main key. Each...
2
by: zek2005 | last post by:
Hi!!!! I have a list of records as a result of a query. They are displayed with a while sentence... while($row = mysql_fetch_array($res)) at the end of each record, I inserted a checkbox...
4
by: JaredEmery | last post by:
Hello all, It's my first database, and I have a query that shows me the quantity, material, length, width and thicknesses of parts, and I'm using these figures to do some arithmetic on a report...
1
by: aaron.reese | last post by:
Guys, this is my problem:- I have records which are linked by two fields on a left inner join (there may be 0,1 or more records in the right hand table) The relationship is not unique (it's...
6
markrawlingson
by: markrawlingson | last post by:
Hopefully someone can help me out with this, it's driving me nuts... I have two tables - We'll call them table1 and table2. Table1 holds event information, and table2 holds user registration data...
1
by: carolyns | last post by:
I am working with Access 2000, on Windows XP (all updates). I designed a survey in Word with 150+ questions. Roughly 60 questions use a lookup list of 7 different responses. I have the survey...
1
by: mahmoodtyagi | last post by:
oci_num_rows(ocirowcount) is always showing 0 records(while having more rows) in PHP with Oracle to fetch total no of records. Code wrote as follows: $qry2="select * from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.