Strings

  • Thread starter Thread starter Loafer
  • Start date Start date
L

Loafer

How can I pad a string with leading 0's in a table if the string doesn't
equal 6 characters ?

Any input would be appreciated
 
Run an Update query on your table. Modify the following
Zip Code example to your specifics.
Table: Employees
Field: Postal Code
Update To: "0" & [Employees]![PostalCode]
Criteria: Len([Employees]![PostalCode])<> "5"

Obviously, in your case, the last line would be <> 6

Roxie Aho
-----Original Message-----
How can I pad a string with leading 0's in a table if the string doesn't
equal 6 characters ?

Any input would be appreciated



------------------------------------------------
 
string = Right("000000" & string, 6)
If it's a numeric value:
string = Right("000000" & trim(str(value)), 6)
In this case it will give you a string return of '001234' of whatever value
you have.
Note: if value is decimal, take into consideration the decimal point and the
decimals or make it integer first.

--
Victor Delgadillo [MVP Access]
Miami, Florida

Consultas al grupo, asi todos nos beneficiamos.

_
 
Here is another way:
Private Sub Command1_Click()
MsgBox "The results are " & Format
Text1.Text, "000000")
End Sub
-----Original Message-----
How can I pad a string with leading 0's in a table if the string doesn't
equal 6 characters ?

Any input would be appreciated



------------------------------------------------
 
Back
Top