Date format

M

Mark

I have a form with an unbound combo box which contains a
list of choices: "Current Month";"Previous Month";"Current
Year", etc. When the user selects a choice, I have vba
code set the value of an unbound textbox on the same form
to something like "Data reflects records for current
month" or ...current year", and so on. The "current
month" format will be "July", etc. Every choice works for
me except the previous month. If the current month is
July, I can get it to read "...6"(for June). My vba code
is Month(Date)-1. But if I use Format(Month(Date)-
1,"mmmm") it says "January". I want the textbox to read
the previous month in "mmmm" format. What am I missing?
Thanks for any help.
 
A

aj

-----Original Message-----
I have a form with an unbound combo box which contains a
list of choices: "Current Month";"Previous Month";"Current
Year", etc. When the user selects a choice, I have vba
code set the value of an unbound textbox on the same form
to something like "Data reflects records for current
month" or ...current year", and so on. The "current
month" format will be "July", etc. Every choice works for
me except the previous month. If the current month is
July, I can get it to read "...6"(for June). My vba code
is Month(Date)-1. But if I use Format(Month(Date)-
1,"mmmm") it says "January". I want the textbox to read
the previous month in "mmmm" format. What am I missing?
Thanks for any help.
.
I'm not sure what you're doing to get the current month
format, but what will sure work even with your last month
format will be a Switch function.

if you're not familiar with the function it works this way

Dim i as Integer

i=2

Switch(i=1,"January",i=2,"February",i=3,"March")

the return value will be "February"

hope that helps!

aj
 
J

John Spencer (MVP)

If I could see your code I could tell you what to change.

You might try something like the following formula:

Format(DateSerial(2000,Month(Date())-1,1),"mmmm")

In Access 2000 or later you might try:
MonthName(Month(Date())-1,False)
 

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