Triming characters

D

Dave

I have a database field that has data like SVC-St Louis.

I want to trim everything left of the "-", including the "-".

How do I do that?

Thanks in advance.

Dave
 
A

Allen Browne

Use InStr() to locate the dash, and Mid() to select the rest of the field:

Try entering something like this into the Field row in query design view:
Mid([MyField], Instr([MyField], "-") + 1)

If that gives you the correct results, you can change the query to an Update
query (Update on Query menu), and move the expression into the Update row.
 
M

Michel Walsh

Hi,


Mid(myString , InStr(myString & "-", "-" ) )



Note that is the character you look for, with InStr, is not found, inStr
returns 0, but Mid( string, 0 ) is an error. On the other hand, Mid(
string, len(string) + 1 ) does not return an error ( return an empty
string). So, to avoid getting a 0, I added the character we look for, to the
string we explore, to be sure we find the character.


Hoping it may help,
Vanderghast, Access MVP
 
D

Dave

Thanks

I love it when a plan works :)

Dave

Allen Browne said:
Use InStr() to locate the dash, and Mid() to select the rest of the field:

Try entering something like this into the Field row in query design view:
Mid([MyField], Instr([MyField], "-") + 1)

If that gives you the correct results, you can change the query to an
Update query (Update on Query menu), and move the expression into the
Update row.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Dave said:
I have a database field that has data like SVC-St Louis.

I want to trim everything left of the "-", including the "-".
 
Top