Solved

Insert hyphens in text string

Posted on 2008-10-08
7
765 Views
Last Modified: 2010-04-21
Good afternoon.  I have been doing alot of reading on this, but, I am having problems with the examples I have tried to use.  My dilemma is this..I have a field entitled [Customer ID] in TblAccounts.  There are 12 characters in each field, and I need to insert two hyphens, one after the third character, and one after the characters from the right.  In other words, I need this:
 009000000010
to look like this :009-0000000-10

Thank you for your time,
Nikki
0
Comment
Question by:Nikki28838
  • 3
  • 2
  • 2
7 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 22672957
You could try the format function:

Format([Customer ID],"000-0000000-00")

Flyster
0
 
LVL 26

Accepted Solution

by:
jerryb30 earned 125 total points
ID: 22672961
select left(customerID, 3) & "-" and mid(customerid, 4,7) & "-" & right(customerid,2) as newCustomerID from tblAccounts
If it is always the two right characters which need a hyphen before them.
0
 

Author Closing Comment

by:Nikki28838
ID: 31504412
Wonderful, thank you very much!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Expert Comment

by:jerryb30
ID: 22673022
I was going to comment that Flyster's solution was more elegant and you ought to ignore my post.
Please consider re-opening for changing score unless there is some reason you cannot make Flyster's solution work.
0
 
LVL 22

Expert Comment

by:Flyster
ID: 22673450
jerryb30,

Thanks for the nice comment. I don't think my work has ever been described as "elegant" before. I have no problem with the points assignment. One nice thing about EE...... there's always another post to respond to! Thanks again.
0
 

Author Comment

by:Nikki28838
ID: 22673512
Hello.  Flysters did work...I just happened to use the other method first because I was in a hurry.  I apologize and will gladly move the points...if someone could tell me how?  Again, so sorry.
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 22673594
You can, if desired, post a request in community support (with a link to this question), asking that it be re-opened for scoring.
Two ways of doing the same thing, but if I had seen Flyster's response before I posted miine (we were within seconds of each other), I would not have posted.  No need to apologize.  I just wanted to be fair to Flyster.
 
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now