Solved

Insert hyphens in text string

Posted on 2008-10-08
7
803 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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