Previous Month in Reports

  • Thread starter Thread starter Trisha
  • Start date Start date
T

Trisha

I have a report that generates the previous month's sales
information. I need to display in the title of this
report Month Ending for... I don't know how I need to
build my expression in order to do this. I need for it to
be If currentmonth = 11, then October, but I need this for
each month. Can anyone help me with how I need to code
this in a report?

Thanks for your help,
Trisha
 
Tricia,

The way I would do this is as follows:
Place a Label (named Lbltitle) in the Header section of
the report and put anything in the caption.
In the Report_Open event use something like this:
Dim Monthname as String
Select Case currentmonth
Case 1
Monthname="December"
Case 2
Monthname="January"

'and so on for all months

Case Else
End Select
Lbltitle.Caption = "Sales For " Monthname

Dave
 
The expression:

Format(DateAdd("m", -1, Date()), "mmmm")

will give you the previous month spelt out in full, e.g. "October".

Thus you can use a TextBox for the Label and set the ControlSource to:

= "Report For " & Format(DateAdd("m", -1, Date()), "mmmm")

to get what you want.
 
Back
Top