Import your data from excel into access, then do an update query:
Update your id_field to the one below:
Right("000000000000" & [ID_Field],12)
Main Topics
Browse All TopicsI need to keep the leading zeros when importing into Access from Excel. I've attached an Excel file and a an Access database with 3 test records. In the Excel file, I have the cells in the column in question defined as "custom" with a format of twelve zeros (000000000000). I also TRIED to do the same thing in Access (defined it as text with a format of 000000000000) but it's not keeping the leading zeros. What am I doing wrong? By the way, as you can see in my Excel file, of the three test records I included, only one is supposed to have leading zeros; that being the '006666666666' record.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
RodgerDjr,
in the Access table you mean? the data type is Text already in the table. If you meant in the Excel file, it seems the only way I can keep the leading zeros in there is if I define the cells as Custom 000000000000, which seems to force it to be a numeric column. In other words, in the Excel file, I don't know how to define the cells/column as text and have it keep leading zeros.
I don't need to export it back to Excel. The data's final resting place is Access. I just want the data to appear in the Access table with the leading zeros. If an update query is the only way to accomplish it, I'll do it. I wonder why though if I (as you can see in the test table) I define the field as text and a format of 12 zeros, that the data isn't appearing/displaying exactly in Access as it does in Excel.
When you have the custom format in Excel it does not store that infomration only the data/number you have typed in.
In Excel before you do the import do this. Hightligt the Column go to tools >> text to columns. Keep the data in the same column and make sure you define the column as text. You could then at this point create a macro that that would look at the length of the cell and then pad to the left the appropriate number of 0's. Then you could do your import into Access.
In Excel you've defined the format as Custom, consisting of 12 characters. Any cell which does not have 12 digits, will be prefixed by zeroes such that always, 12 characters will be displayed. When the spreadsheet is imported into Access, the Access wizard 'sees' the cells as numbers and creates the field accordingly. Probably the easiest way to do what you want is drop the Custom format, leave it as numbers, import the data, create a text cell in the new table, and update the text field from the number field with:
UPDATE myTable SET fldText = Format(fldNumber,"00000000
Business Accounts
Answer for Membership
by: dbfromnewjerseyPosted on 2008-08-05 at 06:43:06ID: 22160753
Here are the files. I already have the three records loaded into my Access test table. You can see the leading zeros are missing from one record that is supposed to have them.
Access database with missing leading zeros
Excel file with leading zeros