combine string

N

Newbie

Hello,

I have a database which has month and year 2 fields, both are text format.
for month, 01,02,03,04...to 12
for year, 05,06,07,08...

I like to convert to one filed and I use str([month]+[year]).
But I got 808,908,1008,1108...
Can I get 0808,0908,1008,1108...?

Thanks


Thankd
 
R

Rui

Just like Gerwin said

use Format([theDate], "mmyy")

Gerwin Berentschot said:
Try to format a string with format (see Access help).

Newbie said:
Hello,

I have a database which has month and year 2 fields, both are text format.
for month, 01,02,03,04...to 12
for year, 05,06,07,08...

I like to convert to one filed and I use str([month]+[year]).
But I got 808,908,1008,1108...
Can I get 0808,0908,1008,1108...?

Thanks


Thankd
 
J

John Spencer

DROP the Str, that is what is stripping off the leading zero
"01" + "08" should give you "0108"

Str("0108") will take the string of numbers, convert it to a number, and then
convert the number (108) back to a string "108".

Perhaps what you meant was you want to use CStr. Although CStr won't handle
null values so you might have to use

CStr(([Month] + [Year]) & "")

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Top