Format textbox number

mafhobb

Registered User.
Local time
Today, 09:15
Joined
Feb 28, 2006
Messages
1,249
Hello.

I have a form with a textbox which gets assigned its value from an autonumber. The autonumber starts at 0 and goes up.

How can I display this autonunmer as a 7-digit number (0000034) instead of just the number itself (34)

Thanks

Mafhobb
 
Hi Maffhob

Simply format the text box as 0000000.

HTH

Swemebegur
 
Just an FYI for you. Formats set at table level don't flow through most of the time. So it is best to set formatting at the latest point possible.
 
That solution works, but only when the data is entered when the form is open. If the form is closed and then reopened, the zeroes are gone.

Suggestions?

mafhobb
 
Not too elegant, but I solved the issue by doing this:
Code:
    'Add forward zeroes to the transaction number for a total of 7 digits
    Dim Transaction
    Dim TransactionLength As Integer
    
    Transaction = Forms![contacts]![Call Listing Subform].Form![CallID].Value
    TransactionLength = Len(Transaction)
    If TransactionLength = 0 Then
        Transaction = "0000000"
    End If
    If TransactionLength = 1 Then
        Transaction = "000000" & Transaction
    End If
    If TransactionLength = 2 Then
        Transaction = "00000" & Transaction
    End If
    If TransactionLength = 3 Then
        Transaction = "0000" & Transaction
    End If
    If TransactionLength = 4 Then
        Transaction = "000" & Transaction
    End If
    If TransactionLength = 5 Then
        Transaction = "00" & Transaction
    End If
    If TransactionLength = 6 Then
        Transaction = "0" & Transaction
    End If

mafhobb
 
I do not understand why you lose the formatting when you close and open the form. This does not happen when I try it. Have you put the 0000000 in the text box, as boblarson pointed out? Can you show us the property sheet for CallID?
 
Hi Swemebegur

Attached you'll find the properties for that textbox.

Thinking about it...could the problem be that the number is actually defined as text in the tables?

mafhobb
 

Attachments

  • prop1.JPG
    prop1.JPG
    74.8 KB · Views: 144
  • prop2.JPG
    prop2.JPG
    68.2 KB · Views: 147
That is probably the reason. In your original post you wrote that it was an autonumber, which is a long integer, and the format I gave applies to these. But why on earth are you copying the autonumber to "txtTrans" instead of just using the autonumber itself?

Swemebegur
 
...good question....why would I not do that???

Thanks Swemebegur...sometimes my brain needs a jump start.

mafhobb
 

Users who are viewing this thread

Back
Top Bottom