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!

Format string output

Status
Not open for further replies.

awelch

Technical User
Apr 24, 2002
85
US
Simple problem, but I just can't seem to get it right.

I have some data that I am inputting into a table set up as a text field. Some of the data is numeric however and whenever input into the tables the first 0 if there is one is dropped. How do I format this to keep the first 0 or multiple 0's if there are any?

Here is the code I am using:

Code:
For i = Val(strLow) To Val(strHigh)
      SQL = "Insert Into TPCT_OUTPUT (TPCT_IPCD_FILL)Values(" + CStr(strLow) + ")"
      CurrentProject.Connection.Execute SQL
      strLow = strLow + 1
Next

Thanks for your help!

Andrea
 
The CStr(strLow) is deleting the leading zeros. Replace it with Format$(strLow, "00000000"), specifying as many zeros as you want digits.

For more information, see the Access 97 help topic "User-defined numeric formats (Format function)".

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top