Solved Label not updating when autoexec (1 Viewer)

mafhobb

Registered User.
Local time
Today, 02:24
Joined
Feb 28, 2006
Messages
1,245
Hi.
I have a db with a report that contains a number of labels. On the onload event of the report the label caption is updated:
Code:
Me.lblToday.Caption = WeekdayName((Weekday(Date, 2))) & ", " & Date

There are two ways that I use this db. The first one is by opening a form and going from there; this report is then accessed through a button on the main form. The second is by using a Windows scheduled task with a macro which calls a function to simply output this report to a folder
Code:
Public Function SendRPTTodayReport()
    DoCmd.OutputTo acOutputReport, "rptTodayReport", acFormatPDF, "\\Servidordatos\IFly\DB Public Data\Today Report\Today" & ".pdf", False, "", 0, acExportQualityPrint
    Application.Quit

End Function
Both of these methods work fine to create the report and show the correct data (from a query), however when using the second method (the autoexec) the label captions do not get updated as they do when opening the report through a form in the database. It is as if the labes "did not have time" to update at all. The end result is that when the report is opened through a database form, the label caption is "Friday, April 21st" (correct), however when using the macro and saving the report, the caption is "Today"(incorrect, not updated). Why?
mafhobb
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:24
Joined
May 7, 2009
Messages
19,243
can you Open the Report "hidden" first, before Outputting?
 

mafhobb

Registered User.
Local time
Today, 02:24
Joined
Feb 28, 2006
Messages
1,245
This did it:
Code:
Public Function SendRPTTodayReport()

    DoCmd.OpenReport "rptTodayReport", acViewPreview, , , acHidden
    DoCmd.OutputTo acOutputReport, "rptTodayReport", acFormatPDF, "\\Servidordatos\IFly\DB Public Data\Today Report\Today" & ".pdf", False, "", 0, acExportQualityPrint

    Application.Quit

End Function
Although the db does open and the report is visible on the screen for a couple of seconds.
Question/thought 1: I presume that I needed to give time to the db to load the report properly before outputing it?
Question 2: Is there any way to make this happen without the db ever being visible, I mean, do this in the background?
 

mafhobb

Registered User.
Local time
Today, 02:24
Joined
Feb 28, 2006
Messages
1,245
Nevermind. I found the option through the task scheduler!
 

Users who are viewing this thread

Top Bottom