I just have a jet ado conn opned.
my db is access
my table is named Mytable
Into field CODE have a value similar:
0500-1
6875-45
...
How to update, with a sql query to format the right item from "-" in #000000 for all value in column field.
and have a result similar
0500-000001
6875-000045
...
format number in field
-
- 5StarLounger
- Posts: 847
- Joined: 24 Jan 2010, 06:35
- Location: A Magic Forest in Deepest, Darkest, Kent
Re: format number in field
Hi Sal
Does this string manipulation function help you:
Left(Code,InStr(Code,"-")) & Format(Right(Code,Len(Code)-InStr(Code,"-")),"000000")
Does this string manipulation function help you:
Left(Code,InStr(Code,"-")) & Format(Right(Code,Len(Code)-InStr(Code,"-")),"000000")
Jerry
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: format number in field
hi friend but i need the sql commandJezza wrote:Hi Sal
Does this string manipulation function help you:
Left(Code,InStr(Code,"-")) & Format(Right(Code,Len(Code)-InStr(Code,"-")),"000000")
similar sql="....."
-
- 5StarLounger
- Posts: 776
- Joined: 29 Jan 2010, 13:30
Re: format number in field
Sorry - forgot to credit Jezza with the superb code in my earlier posting.
Silverback
=================================================================
I tried this and it worked OK for me.
UPDATE MyTable SET MyTable.Code = Left(
Silverback
=================================================================
I tried this and it worked OK for me.
UPDATE MyTable SET MyTable.Code = Left(
Code: Select all
,InStr([Code],"-")) & Format(Right([Code],Len([Code])-InStr([Code],"-")),"000000");
Hope this helps
Silverback
Last edited by silverback on 05 Oct 2010, 17:17, edited 1 time in total.
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: format number in field
silverback wrote:I tried this and it worked OK for me.
UPDATE MyTable SET MyTable.Code = Left(Code: Select all
,InStr([Code],"-")) & Format(Right([Code],Len([Code])-InStr([Code],"-")),"000000"); Hope this helps Silverback[/quote] Perfect! Tks. Sal.