Insert a character into a string

G

Guest

Hello,
I need to insert a hyphen into a text field (Field1) in a table.
For example, the data for Field1 = "1234567". I want to insert a hyphen
after the 3rd character, so Field1 = "123-4567". Is there a built-in function
in Access 2000? Any help is very much appreciated.
 
M

Marshall Barton

Samantha said:
I need to insert a hyphen into a text field (Field1) in a table.
For example, the data for Field1 = "1234567". I want to insert a hyphen
after the 3rd character, so Field1 = "123-4567". Is there a built-in function
in Access 2000? Any help is very much appreciated.

Not that I know of, but you can use an expression in a query
field:

IIf(Mid(field1, 4, 1) <> "-", Left(field1, 3) & "-" &
Mid(field1, 4), field1)
 
G

Guest

It works! thank you so much!.

Marshall Barton said:
Not that I know of, but you can use an expression in a query
field:

IIf(Mid(field1, 4, 1) <> "-", Left(field1, 3) & "-" &
Mid(field1, 4), field1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top