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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Field Properties

Status
Not open for further replies.

notdorothy

Programmer
Joined
Mar 22, 2001
Messages
1
Location
US
I have someone who is wanting to create a number field 8 characters long and if the user only enters say "23" he wants the computer to fill in the last 6 characters with zero. What is the easiest way for him to accomplish this??
 
Hi notdorothy,
Here is a snippet of code I have which takes a given (integer) project ID and displays it in a text box with 6-digits, including leading zeros. Please let me know if you would like any further help in converting it to your use:

--- Begin Code ---
Dim intNewProjectID As Integer, strNewProjectID As String
Dim intNumberLeadingZeros As Integer
Const TotalCharsInNewProjectID = 6

intNewProjectID = rstNewProjectID![New Project ID]
'Add leading zeros to string value
strNewProjectID = String((TotalCharsInNewProjectID - _
Len(Format(intNewProjectID))), "0") & _
Format(intNewProjectID)
'Set value in box to suggested new value
txtSuggestedProjectID.Value = strNewProjectID
--- End Code ---


Hope that helps! :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top