Padding out numbers

Matt Brown

Registered User.
Local time
Today, 12:44
Joined
Jun 5, 2000
Messages
120
Hi all,

Havent been here for a while.

I am trying to pad out a number so that it always displays 8 digits and starts from the right ie

00000315

00000316

etc, etc

i am using the following as it is a barcode in a control source field:

="*" & "00000000" & [UnitSN] & "*"

At the moment this adds 8 zeros to the UnitSN number.

I have tried using Right$() function but cannot get it to accept it.

Anyone have any ideas please.
Barcode font is code39.

Thanks

Matt
 
Right("00000000" & [UnitSN], 8) should work, but a simpler expression is Format([UnitSN],"00000000").
 
A code method:

Code:
    Dim l As Integer, i As Integer
    
    l = Len(Me.Text0)
    
    If l < 8 Then
        i = 8 - l
        Do While i > 0
            Me.Text0 = "0" & Me.Text0
            i = i - 1
        Loop
    End If


Or, CStr(Format(Me.Text0, "00000000"))


Both of these will let you store the full 8 digit value in a table.
 

Users who are viewing this thread

Back
Top Bottom