Date format

  • Thread starter Thread starter Mark
  • Start date Start date
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.
 
-----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
 
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)
 
Back
Top