Putting date in Report Header

G

Guest

I want to put the date in the header of a couple of my reports. The only
catch is that I need the date that is added to be dependent on the time of
day the report is generated. For example, if the report is generated before
8AM it should have today's date. After 8AM it should have tomorrow's date.
I have tried the following code, but it always gives me tomorrow's date:
=IIf(Time()>"8:00:00 AM",Date(),Date()+1)

This is probably an easy fix, but I guess I am overlooking it.

Thanks in advance.
 
J

Josh Nankivel via AccessMonster.com

Put this into the onload event of your report:


If Time() > "8:00:00AM" Then
Me.Caption = Date + 1
Else
Me.Caption = Date
End If
 
A

Allen Browne

Set these properties for your text box:
ControlSource: =DateAdd("h", 16, Now())
Format: Short Date
 
J

Josh Nankivel via AccessMonster.com

I'm sorry, that code will actually change the caption of the report, so if
you export to PDF the filename will be the caption.

For your purposes, you can do much the same thing, except instead of
me.caption just refer to the control on the report you want to change.
 

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