?
Solved

Update Query - Pad String with Leading Zeros

Posted on 2002-07-24
3
Medium Priority
?
641 Views
Last Modified: 2010-07-27
I am trying to write an update query that will convert all of my records in a field to 14 digits with leading zeros (0).

So, instead of
19750
745513265

I would like
00000000019750
00000745513265

In Excel, I do it using =Rept("0",14-Len(B1))& B1, but cannot figure out the syntax in Access.

This must be simple, but I am tearing my hair out.  Please help.  Thanks.
0
Comment
Question by:lstaple
[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
  • 2
3 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 200 total points
ID: 7175723
You don't really need this as you can always use the format statement to "mimic" this behaviour.

But you can also use it to transform the field.
First add a text field as I assume it's now numeric..

Then use =format([fieldname],"00000000000000") in an update query to get the field transformed.

Nic;o)
0
 

Author Comment

by:lstaple
ID: 7175766
That did the trick!  Thank you so much; the answer had eluded me for several days.
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7175806
Then next time use EE sooner ;-)
I personally stop working on a problem when it takes longer as one hour. Then it's time to ask a collegue (or EE)

Success with the application !

Nic;o)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

777 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