Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom format for integer fields

Status
Not open for further replies.

BitCounter

Programmer
Feb 18, 2000
28
US
Anybody!<br><br>&nbsp;&nbsp;&nbsp;&nbsp;I have a table with a field for holding an ID number.&nbsp;&nbsp;Whenever the user enters an ID, I would like this number to be saved with any necessary leading zeros.&nbsp;&nbsp;My field length is 10 spaces, therefore, if my user entered 12.&nbsp;&nbsp;I would like the following to be stored:&nbsp;&nbsp;0000000012<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;What do I need to do to make this happen?<br><br>&nbsp;&nbsp;Any help would be greatly appreciated!<br><br>Renae
 
Open the table in design view, change the Format property of your ID field to 0000000000 (ten zeros), this will do what you want. If you wish to see this in you forms or reports, you will need to change the Format properties of your objects to the same as above.<br><br>Good Luck,<br>RDH<br><br> <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
 
To have the extra zeros saved perhaps you could make the field a text field:<br><br>Try the following:<br>Create a form for the table and then write an afterupdate event using VBA for the ID field.&nbsp;&nbsp;<br><br>dim varID as string<br>do until len(varID)=10<br>&nbsp;&nbsp;&nbsp;varID=&quot;0&quot; & varID<br>Loop<br>Me!ID=varID
 
Thank you both very much for your response.&nbsp;&nbsp;RHicks, I tried that, but for some reason it just didn't work for me.&nbsp;&nbsp;Cornerstone....you hit the spot!&nbsp;&nbsp;Great Job..it works exactly as I need it to.&nbsp;&nbsp;Both of your responses are what makes forums like this great.&nbsp;&nbsp;Thanks again -- you made my day.<br><br>Renae
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top