Microsoft
Software
Hardware
Network
Question : Leading zeros
I have a column of numbers imported from a spreadsheet that are five, six or seven digits in length, and they need to be updated to all be eight digits in length by inserting leading zeros.
Two questions:
First, is there a simple update query that will do this?
Second, is there a simple function I can write that will do this when I import the spreadsheet?
Thanks!
Answer : Leading zeros
The zero's will disappear because Access will make the fielddefinition numeric when it finds numbers in the first eight rows :-(
Importing a table like this (with a "textnumber") I do with copying the header row with the fieldnames to row 2 of the sheet.
Now every column will be imported as text, but the cost is that the additional header row will have to be removed after the import...
For adding the leading zero's you have already two solutions, here a third:
UPDATE tblImport SET fieldtextnumber = right("00000000" & fieldtextnumber,8)
An alternative might be to link a table to the excelsheet (new table > link > chose .xls as filetype) and create a maketable query (or append query) to fill the final table directly in the proper way.
In that query you can also use the "add leading zero's code" from the above UPDATE statement.
Clear ? :-)
Nic;o)
Random Solutions
Hyper-V Core 2008R2 Cluster Issues with volumes
convert a jpg, jpeg, bmp,tiff or gif images in a ico image
Windows SharePoint Services errors (error codes 6398, 7076, 6482)
Store data to a record encrypted?
How to keep Visual Studio 2008 from trashing conditional code in my C/C++ Resource File?
MS Server 2003 - Missing gpedit.msc
Need Win98 compatible laser printer
Run-time error '2450'. Microsoft Access can't find form 'frmTenants'
How to Detect Movement from a Datasheet to a SubDataSheet
Link Excel Workbook to Access