Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Month Name on a Report 1

Status
Not open for further replies.

dixie617

Programmer
Jun 8, 2005
62
US
Hello,

I am trying to remember how to put the Month Name on a report using a text box formula, what I need is for the report to show at the top "Report for the Month of & (previous month's Name)" I know I need to use the MonthName function but after that I am lost, it has been a while since I programmed in access.

Thanks

Dixie
 
=MonthName(Month(DateSerial(Year(Now()),Month(Now()),0)))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This is pretty much what I was needing thanks, but, how do I make it last month, for example I am running a report for November and it is now December, then what happens when I run December's in January will it work?

Thanks

Dix
 
dixie617 -

Just a little explanation about the DateSerial part of the function that PHV gave you.

With DateSerial, it uses the syntax

DateSerial(Year, Month, Day)

And the first day of the month is 1, so the day before the first day of the month listed is 0, which when used like that always gives you the last day of the month preceding the one you had in the Month slot.

So, if you wanted to find the last day of the month for next month you would use

DateSerial(Year(Date), Month(Date)+2, 0)

Since Next month means we are still in this month, if I add one to this month and then take 0 as the day it would show me the last day of this current month. So we have to add 2 to the month to get to the right location.

Hope that helps you understand the DateSerial function a bit more and you can see that it is a very powerful tool to have in your arsenal.



Bob Larson
FORMER Microsoft Access MVP (2008-2009, 2009-2010)
Free Tutorials/Samples/Tools:
 
Bob,

That explained a lot thank you for the infomration I have saved it to my postings and archive so I will have it in the future.

Dix
 
Bob, thanks for that. I wasn't aware that Dateserial could use the Day = 0 to get the last day of the previous month. Good to know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top