Input Masks - Leading Zeros

C

Cheryl

I am trying to create a new database using Access 2007. One of the tables
will be an employees table. Our employees have badge numbers that can be 4
to 6 numeric digits. I would like to be to enter a badge number as, for
example, 1234, and have Access save it as 001234, but I haven't been able to
figure out an input mask to do this.

Can anyone help me?

Thank you.
 
F

fredg

I am trying to create a new database using Access 2007. One of the tables
will be an employees table. Our employees have badge numbers that can be 4
to 6 numeric digits. I would like to be to enter a badge number as, for
example, 1234, and have Access save it as 001234, but I haven't been able to
figure out an input mask to do this.

Can anyone help me?

Thank you.

No Input Mask is necessary.
As a number, 1234 has the same value as 001234.
If the [BadgeNumber] field's datatype is Number it will NOT store
preceding zeros.

Set the table's [BadgeNumber] field's Datatype to Text.
Now you can save preceding zeros.

On the form you use for data entry, code the [BadgeNumber] control's
AfterUpdate event:

Me.[BadgeNumber] = Format([BadgeNumber],"000000")

Enter 1234 and Access will save it as 001234.
 
J

Jeff Boyce

Cheryl

Why? If you are looking to see 6 characters, you can use formatting (not
storing) to accomplish that.

By the way, unless you are planning to "do math" on those, the badge
"numbers" aren't "numbers"! As suggested elsethread, make them text
instead, to avoid the confusion about whether you can do math on them.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
J

John W. Vinson

G

Gloops

How? Please!

TIA

Hello,

If I do not mix up with something else, you have to consider
- format : for the display
- inputmask : for the input

In the format you have to distinguish #, that stays for a figure except
a leading zero, and 0, where a leading zero will appear.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top