Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

I need a query that formats a set of numbers.

Posted on 2008-06-23
5
Medium Priority
?
205 Views
Last Modified: 2011-10-19
I just need an Access Query that changes the format of a set of numbers like this

08-01-   6-0059-0000-0000

into this

0801-0006-0059-0000-0000

Thank you
0
Comment
Question by:GravitaZ24
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 21847900
If your first set of numbers is always in that format, then this should work for you:

NewFormat: Left([YourNumberField],2) & Mid([YourNumberField],4,2) & "-000" & Mid([YourNumberField],8,1) & "-" & Right([YourNumberField],14)

Flyster
0
 

Author Comment

by:GravitaZ24
ID: 21848710
I'm sorry that worked for the first few numbers, but there was more to it than I realized, I attached a sample of the numbers, I have to get them into this format xxxx-xxxx-xxxx-xxxx-xxxx-xxx. The second groups of numbers is where i'm having trouble, they have to be filled in with zeros where there are blanks.
0
 

Author Comment

by:GravitaZ24
ID: 21848716
I forgot to attach to the last post, here it is
Sample.xls
0
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 21849440
See if this works for you:

SELECT Sheet1.[Unique], Replace([Unique],"-","") AS Step1, Replace([Step1]," ",0) AS Step2, Format([Step2],"0000-0000-0000-0000-0000-000") AS Step3
FROM Sheet1;
0
 

Author Closing Comment

by:GravitaZ24
ID: 31469815
Thank you! that worked!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Screencast - Getting to Know the Pipeline

879 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