RE: Automatic Preceeding Zeros in a field e.g. 00001234
From: Jay Vinton (JayVinton_at_discussions.microsoft.com)
Date: 06/19/04
- Next message: cheza: "how do i create a table, record sheet ?? help?"
- Previous message: Jay Vinton: "RE: Retrieving Records from another database"
- In reply to: DD: "Automatic Preceeding Zeros in a field e.g. 00001234"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Jun 2004 21:55:01 -0700
> are not yet 8 characters be preceeded by zeros without the
> user having to input the zeros.
If the data needs to be a number, you must deal with the formatting in code at runtime. If your objective is to always have 8 characters in the table, then it should be type String.
Assuming the second case, make the serial number type Text and massage it in code before saving.
This is a good time to stop and think. Will today's serial number format be workable in the future? What if you want to change "00000123" to "ABC-0123" or "ABC-XY-1234567890-P"? If you plan ahead, you'll save a lot of grief when things change.
To solve your immediate problem:
Dim str as String
str = CStr(123)
Do While (Len(str) < 8)
str = "0" & str
Loop
' str = "00000123"
Jay
- Next message: cheza: "how do i create a table, record sheet ?? help?"
- Previous message: Jay Vinton: "RE: Retrieving Records from another database"
- In reply to: DD: "Automatic Preceeding Zeros in a field e.g. 00001234"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|