Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Insert a character into a string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Samantha - 08 Nov 2005 20:02 GMT
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.
Klatuu - 08 Nov 2005 20:09 GMT
Field1 = replace(Field1,mid(Field1,3,1),mid(Field1,3,1) & "-")

> 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.
Marshall Barton - 08 Nov 2005 20:20 GMT
>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)

Signature

Marsh
MVP [MS Access]

Samantha - 08 Nov 2005 21:59 GMT
It works! thank you so much!.

> >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
[quoted text clipped - 6 lines]
> IIf(Mid(field1, 4, 1) <> "-", Left(field1, 3) & "-" &
> Mid(field1, 4), field1)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.