themurph2000
09-25-2007, 12:06 PM
This is probably an easy question by comparison to some of these others.
I have a table where a transaction number is always 8 digits. If the number is not 8 digits, it should start with zeros, such as
12345 should be 00012345
123456 should be 0123456
Is there a simple and fast way to do this? It can also be done in a form, since I enter the data through there. Will it be necessary to change the field from a number to a text data type?
KenHigg
09-25-2007, 12:12 PM
Just my preference but I'd put a mask at the table level that requires the full 8 characters and yes they need to be text not numeric...
:)
ken
themurph2000
09-25-2007, 12:36 PM
Just my preference but I'd put a mask at the table level that requires the full 8 characters and yes they need to be text not numeric...
:)
ken
I can see that, but since the item I wish to add is a 0, and 0 is used as code in an input mask, does anybody know the correct coding to do it?
boblarson
09-25-2007, 12:40 PM
Actually, you can still store the number as is, but have leading zeros displayed (no need to change it to text).
Just set the format property (any time you use it) to 00000000
themurph2000
09-25-2007, 01:18 PM
Actually, you can still store the number as is, but have leading zeros displayed (no need to change it to text).
Just set the format property (any time you use it) to 00000000
That's the solution, but the part I didn't figure out is I have to put that format in the queries and reports that use it. They don't get passed on from the original data in the table.
boblarson
09-25-2007, 02:29 PM
That's the solution, but the part I didn't figure out is I have to put that format in the queries and reports that use it. They don't get passed on from the original data in the table.
Yes, that's why I said "anytime you use it"
themurph2000
09-25-2007, 02:32 PM
Yes, that's why I said "anytime you use it"
Oops, there goes the light bulb over my head. Now I know why OSHA says you have to be away from your computer 10 minutes out of every hour.
KenHigg
09-25-2007, 04:30 PM
In any case there's still no reason to store it as a number as you simply mask for numerics. :)
themurph2000
09-26-2007, 07:22 AM
In any case there's still no reason to store it as a number as you simply mask for numerics. :)
This is true. However, given that there's no way to know how many actual digits there are, only that it has to be filled to 8, boblarson's idea works best. Actually, I had thought of that one before but did not realize back a few months ago that the format had to be changed EVERYWHERE, not just in your table or form. (Would have saved myself several Tylenol knowing that)