Determining when a report printed

K

kateri4482

Is it possible to determine when a report printed (or print previewed) - and
maybe even who printed it? In other words, I want to run a report, and then
the next time I run it I am selecting records that changed since the last
time the report ran. Does that make sense? Any assistance is appreciated.
 
F

fredg

Is it possible to determine when a report printed (or print previewed) - and
maybe even who printed it? In other words, I want to run a report, and then
the next time I run it I am selecting records that changed since the last
time the report ran. Does that make sense? Any assistance is appreciated.


I'll assume you mean to save the time as well as the date the report
is run.
You could create a new table.
Table Name "tblReportRun"
Field Name "OnDate" DateTime datatype
As the first (and only record) enter the current date and time.

Then code the Open event of the report:

CurrentDb.Execute "Update tblReportRun Set tblReportRun.OnDate =
Now()", dbFailOnError

Each time you print or preview the report, the current date and time
will be entered into that field.

You could then use that field as criteria for the next report:

Either:
Select YourTable.FieldName, .... etc ... From YourTable
Where YourTable.DateField > DLookUp("[OnDate]","tblReportRun")

or...
Include the tblReportRun Table in the query.
Drag the OnDate field onto the grid along with your other fields.
Then as criteria on your DateField, write:
 
K

kateri4482

Thank you. This makes total sense. I did as you suggested and added
tblReportRun to the query, and in the criteria I put > OnDate. However, I
keep getting a "Data type mismatch in criteria expression" when I run the
query. Without that criteria, it runs fine, even if the information is not
what I am looking for, at least it runs. I can't figure out what the
mismatch is. Any thoughts?

fredg said:
Is it possible to determine when a report printed (or print previewed) - and
maybe even who printed it? In other words, I want to run a report, and then
the next time I run it I am selecting records that changed since the last
time the report ran. Does that make sense? Any assistance is appreciated.


I'll assume you mean to save the time as well as the date the report
is run.
You could create a new table.
Table Name "tblReportRun"
Field Name "OnDate" DateTime datatype
As the first (and only record) enter the current date and time.

Then code the Open event of the report:

CurrentDb.Execute "Update tblReportRun Set tblReportRun.OnDate =
Now()", dbFailOnError

Each time you print or preview the report, the current date and time
will be entered into that field.

You could then use that field as criteria for the next report:

Either:
Select YourTable.FieldName, .... etc ... From YourTable
Where YourTable.DateField > DLookUp("[OnDate]","tblReportRun")

or...
Include the tblReportRun Table in the query.
Drag the OnDate field onto the grid along with your other fields.
Then as criteria on your DateField, write:
 
K

kateri4482

Never mind. I figured it out. Duh.

kateri4482 said:
Thank you. This makes total sense. I did as you suggested and added
tblReportRun to the query, and in the criteria I put > OnDate. However, I
keep getting a "Data type mismatch in criteria expression" when I run the
query. Without that criteria, it runs fine, even if the information is not
what I am looking for, at least it runs. I can't figure out what the
mismatch is. Any thoughts?

fredg said:
Is it possible to determine when a report printed (or print previewed) - and
maybe even who printed it? In other words, I want to run a report, and then
the next time I run it I am selecting records that changed since the last
time the report ran. Does that make sense? Any assistance is appreciated.


I'll assume you mean to save the time as well as the date the report
is run.
You could create a new table.
Table Name "tblReportRun"
Field Name "OnDate" DateTime datatype
As the first (and only record) enter the current date and time.

Then code the Open event of the report:

CurrentDb.Execute "Update tblReportRun Set tblReportRun.OnDate =
Now()", dbFailOnError

Each time you print or preview the report, the current date and time
will be entered into that field.

You could then use that field as criteria for the next report:

Either:
Select YourTable.FieldName, .... etc ... From YourTable
Where YourTable.DateField > DLookUp("[OnDate]","tblReportRun")

or...
Include the tblReportRun Table in the query.
Drag the OnDate field onto the grid along with your other fields.
Then as criteria on your DateField, write:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top