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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number to month

Status
Not open for further replies.

ivow

Programmer
Aug 6, 2002
55
CA
Hi all,

I have a parameter query that requires the user to enter the number of the month [1-12], however I'd like the name of month [January-December] to apppear on the report.

Can I create an if statement in a text box?

ivo "If it's stupid but works, it isn't stupid."
 
Hi,
Why not create a new table called "Month". The primary key will be the month number(e.g., Month_numb), and the Month_desc will contain the name of the month. Then, simply add that to your query, and select the Month_desc to appear on the report. If this tip has been helpful, be sure to click on the "Mark this post as a helpful/expert post!".

Randy Smith
California Teachers Association
 
That sounds like a good idea.

But I read a bit further down the posts and saw the question with the if statement below and decided to create a module that handles it.

like so:


Public Function GetValue(strInput As String) As String

Select Case strInput
Case "1": GetValue = "January"
Case "2": GetValue = "February"
Case "3": GetValue = "March"
Case "4": GetValue = "April"
Case "5": GetValue = "May"
Case "6": GetValue = "June"
Case "7": GetValue = "July"
Case "8": GetValue = "August"
Case "9": GetValue = "September"
Case "10": GetValue = "October"
Case "11": GetValue = "November"
Case "12": GetValue = "December"
Case Else: GetValue = "BAD MONTH"
End Select
End Function

There's probably better ways to do it...
"If it's stupid but works, it isn't stupid."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top