Trying to write a procedure that will print a report that contains only the data that is new since the last time the report was printed. I created a single-record, 2-field table to hold two dates: the date the report was last printed and the previous date is was printed. I use that information as criteria in my query. Straight forward so far…
My procedure is written so that it updates the two dates in the table to their appropriate values, then fires the report. When I “watch” these fields and their corresponding variables from within the VBA editor, I see that they update correctly. However, when the report runs, the old dates are used. When I open the table, sometimes the new dates are there, sometimes the old dates are there. It’s the strangest thing.
Here is the code I’m using to update the fields, etc.
Dim dtLastDateRun As Date
Dim dtPreviousDateRun As Date
‘get the current ‘LastRunDate’
dtPreviousDateRun = DLookup(“LastDateRun”, “tblWeeklyLabelsLastDate”)
‘move ‘LastDateRun’ value to ‘PreviousDateRun’ in the table
PreviousDateRun = dtPreviousDateRun
‘move yesterdays date to ‘LastDateRun’
dtLastDateRun = Date – 1
LastDateRun = dtLastDateRun
There’s probably an easier way to do this. Thanks for any help.