Add one space before the last charecter (1 Viewer)

ardy

Registered User.
Local time
Today, 06:33
Joined
Sep 24, 2012
Messages
98
Hello All,
I am trying to construct a update Query to add a space right before the last character. but am having a hard time:banghead:.... can anybody point me to the right direction.


Example:
Book
Door
Sliding Door
Jam


Should look like this after the Query



Boo k
Doo r
Sliding Doo r
Ja m



Any help is appreciated.....
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:33
Joined
Aug 30, 2003
Messages
36,134
One way (Immediate window test):

?left("blah blah",len("blah blah")-1) & " " & right("blah blah", 1)
blah bla h
 

ardy

Registered User.
Local time
Today, 06:33
Joined
Sep 24, 2012
Messages
98
Thank you for the response.....Tried


Left([T_lab_anl_method_name],-1) & " " & Right([T_lab_anl_method_name],1)


it gives me can't update all the records violation error. but if I take the negative out it works but the result is not what i was aiming for.


Ardy
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:33
Joined
May 21, 2018
Messages
8,610
I am assuming that was a typo. I think he meant the length of the field minus 1
Code:
Left([T_lab_anl_method_name],len([T_lab_anl_method_name])-1)
 

isladogs

MVP / VIP
Local time
Today, 14:33
Joined
Jan 14, 2017
Messages
18,259
You didn't copy Paul's code correctly. Try this:

Left([T_lab_anl_method_name],Len([T_lab_anl_method_name])-1) & " " & Right([T_lab_anl_method_name],1)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:33
Joined
Aug 30, 2003
Messages
36,134
No typo, it was there and missed:

One way (Immediate window test):

?left("blah blah",len("blah blah")-1) & " " & right("blah blah", 1)
blah bla h

Send garlic. :p
 

ardy

Registered User.
Local time
Today, 06:33
Joined
Sep 24, 2012
Messages
98
What if the length varies, i.e


Book
Door
Sliding Door
Jam
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:33
Joined
Aug 30, 2003
Messages
36,134
Have you tried it? The Len() function accounts for varying length. That said, an empty field could be a problem.
 

ardy

Registered User.
Local time
Today, 06:33
Joined
Sep 24, 2012
Messages
98
Oh.... I got it......
Never mind it works perfect......... Thank you all


Left([T_lab_anl_method_name],Len([T_lab_anl_method_name])-1) & " " & Right([T_lab_anl_method_name],1)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:33
Joined
Aug 30, 2003
Messages
36,134
Happy to help.
 

isladogs

MVP / VIP
Local time
Today, 14:33
Joined
Jan 14, 2017
Messages
18,259
As Paul mentioned, that code will fail if your field is empty.
Here's one way of handling that issue

Code:
IIf(Len([T_lab_anl_method_name])>0,Left([T_lab_anl_method_name],Len([T_lab_anl_method_name])-1) & " " & Right([T_lab_anl_method_name],1),"")
 

Users who are viewing this thread

Top Bottom