Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA to Record How Many Times Reports Are Opened?

Status
Not open for further replies.

dmon000

Technical User
Sep 9, 2003
79
US
Does anyone know of a VBA routine that will load on database open that will record the names of all reports as opened and increment a counter field in a table?

I'm looking for code that does not need to be in each individual report.

THANKS!

PS: I apologize for posting this in the wrong forum earlier. I was looking for a way to remove the earlier posting, but could not find a way.
 
Without code in each report, how will you tell which report is opened?

Writing a fairly simple routine that can increment a counter as a report is opened and record this, but it will need to be called from the report itself, probably in the Report_Open event.

John
 
I was looking for a way to remove the earlier posting, but could not find a way
simply Red Flag it.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Not any built-in method that I know of.

I usually use a single form that lists all the reports in a listbox. When they select a report, on the right side controls are displayed for entering the parameters.

If you used such a centralized approach for reports, you could write your counting function in that form.


 
How are ya dmon000 . . .

You could get a handle on this if you open your forms thru a common routine. Here's an example to start you off, and [blue]note the code doesn't need to run at startup[/blue]. It works whenever you open a report:
Code:
[blue]Public Sub CountReports([purple][b][i]rptName[/i][/b][/purple] As String, rptView As Integer)
   Dim db As DAO.Database, rst As DAO.Recordset
      
   DoCmd.OpenReport [purple][b][i]rptName[/i][/b][/purple], rptView
   
   Set db = CurrentDb
   Set rst = db.OpenRecordset("[purple][b][i]TableName[/i][/b][/purple]", dbOpenDynaset)
   
   rst.Edit
   rst([purple][b][i]rptName[/i][/b][/purple]) = rst([purple][b][i]rptName[/i][/b][/purple]) + 1
   rst.Update
   
   Set rst = Nothing
   Set db = Nothing

End Sub[/blue]
A call would look like:
Code:
[blue]   Call CountReports("rptAccounting", acViewPreview)[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Woops! . . .

[blue]forms[/blue] in my first sentence (prior post) should read [blue]reports[/blue] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top