Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is it possible....

0 views
Skip to first unread message

Jacob

unread,
Nov 13, 2008, 2:52:51 PM11/13/08
to
I have a report. In one field of the report, it is bringing back a number.
Where the number is, I would like to replace it with a text I tried the IF
THEN ELSE but did not work. Is there a way to use the SELECT CASE?


Jacob

unread,
Nov 13, 2008, 2:56:15 PM11/13/08
to
Here is a copy of what I tried...

If Me.pmmonth.Value = 1 Then
Me.pmmonth.Value = "Jan"
ElseIf Me.pmmonth = 2 Then
Me.pmmonth = "Feb"
ElseIf Me.pmmonth = 3 Then
Me.pmmonth = "Mar"
ElseIf Me.pmmonth = 4 Then
Me.pmmonth = "Apr"
ElseIf Me.pmmonth = 5 Then
Me.pmmonth = "May"
ElseIf Me.pmmonth = 6 Then
Me.pmmonth = "Jun"


End If

"Jacob" <jse...@intermed1.com> wrote in message
news:e2s2qlcR...@TK2MSFTNGP06.phx.gbl...

Jeff Boyce

unread,
Nov 13, 2008, 3:30:20 PM11/13/08
to
I'll take a wild guess that you are trying to display the first three
characters of month names.

Depending on what the underlying field is (e.g., a date/time field), you
could simply use the Format() function to return the three-character
monthname without saving/storing pmmonth.Value at all!

Good luck

Regards

Jeff Boyce
Microsoft Office/Accesss MVP


"Jacob" <jse...@intermed1.com> wrote in message

news:eYNekncR...@TK2MSFTNGP04.phx.gbl...

Klatuu

unread,
Nov 13, 2008, 3:34:18 PM11/13/08
to
First, you need to be referencing the field that contains the data, not the
control bound to the field. For what you want, you can do this in the
Control Source of the control:

=Choose([pmmonth], "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec")

Where [pmmonth] is the name of the report's recordset field.

"Jacob" <jse...@intermed1.com> wrote in message
news:e2s2qlcR...@TK2MSFTNGP06.phx.gbl...

Dirk Goldgar

unread,
Nov 14, 2008, 12:27:25 PM11/14/08
to
"Jacob" <jse...@intermed1.com> wrote in message
news:e2s2qlcR...@TK2MSFTNGP06.phx.gbl...
>I have a report. In one field of the report, it is bringing back a number.
>Where the number is, I would like to replace it with a text I tried the IF
>THEN ELSE but did not work. Is there a way to use the SELECT CASE?


I'll chime in with a third approach, if what you want is to translate a
month number into a month name. You can use the MonthName function. It can
give you either the full name or an abbreviation, depending on an optional
argument. For example,

?MonthName(11)
November
?MonthName(11, true)
Nov


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Klatuu

unread,
Nov 14, 2008, 3:41:30 PM11/14/08
to
@#$5t354#Y#%#T!!!
I thought I knew all my functions!

"Dirk Goldgar" <d...@NOdataSPAMgnostics.com.invalid> wrote in message
news:ulfJG5nR...@TK2MSFTNGP05.phx.gbl...

Dirk Goldgar

unread,
Nov 14, 2008, 4:43:27 PM11/14/08
to
"Klatuu" <david....@realpage.com> wrote in message
news:u$iTglpRJ...@TK2MSFTNGP06.phx.gbl...

> @#$5t354#Y#%#T!!!
> I thought I knew all my functions!


<g> There's no end to them! But how come the one I want is never in the
list?

Jacob

unread,
Nov 17, 2008, 6:30:42 PM11/17/08
to
This seems right. However, I may not know how to place this code in. I have
never used the MonthName function. May I ask you how I would place that in
my code? Sorry for such a novice question, I am self taught in Access and
learning every day. I am also sorry it took me so long to get back to this.

"Dirk Goldgar" <d...@NOdataSPAMgnostics.com.invalid> wrote in message
news:ulfJG5nR...@TK2MSFTNGP05.phx.gbl...

Dirk Goldgar

unread,
Nov 18, 2008, 11:20:19 AM11/18/08
to
"Jacob" <jse...@intermed1.com> wrote in message
news:OUD5$xQSJH...@TK2MSFTNGP03.phx.gbl...

> This seems right. However, I may not know how to place this code in. I
> have never used the MonthName function. May I ask you how I would place
> that in my code? Sorry for such a novice question, I am self taught in
> Access and learning every day.

We're always glad to teach. We don't have much information to answer your
question, though. I understand from your posts in this thread that you're
working with a report, and that there is a field named "pmmonth", which is a
month number 1-12. You want to display the (abbreviated) name of the month
on the report instead of the number.

I'm going to guess that you currently have a text box on the report that has
"pmmonth" as its ControlSource property. Quite likely the text box is also
named "pmmonth". We're going to change its ControlSource property, and also
its Name property. Change those properties as follows:

Control Source: =MonthName([pmmonth])
Name: txtPMMonthName

That ought to do it -- you don't have to write any VBA code of your own.

Incidentally, the reason you have to change the name is that it would be
confusing to Access if you had a control named "pmmonth" which wasn't bound
directly to the pmmonth field. There would then be two wholly distinct
things named "pmmonth", and Access would not know which was meant in any
context.

Please let me know if that solves your problem.

0 new messages