Phone number format in text box

G

Guest

Hi.. I'm setting up a form with text boxes for entering phone numbers. When
I test it, an error comes up saying that maybe I've entered too many
digits...

On the table design view, I've set the associated field data type as
"number" - where do I specify the number of digits. ALSO: is there a way to
"force" the form to display the entered digits as (000) 000 0000, or
000-000-0000 ?

THANKS SO MUCH
 
J

John Vinson

Hi.. I'm setting up a form with text boxes for entering phone numbers. When
I test it, an error comes up saying that maybe I've entered too many
digits...

On the table design view, I've set the associated field data type as
"number" - where do I specify the number of digits. ALSO: is there a way to
"force" the form to display the entered digits as (000) 000 0000, or
000-000-0000 ?

THANKS SO MUCH

If you can be CERTAIN that you will *never* need to enter non-North
American phone numbers (many countries have quite different phone
number conventions), and you will be storing phone extensions in
another field, you can use the Phone Input Mask on the field. The
Phone field should be of Text datatype (NOT Number!), ten characters
long; the Input Mask wizard will give you a decent default which will
display (000) 000-0000 when you enter 0000000000.

John W. Vinson[MVP]
 
G

Guest

That method seems simple enough but does not work for me.

Both the control format and mask do not work as expected.

I am using access 2003. The form is connected to a table and this field (
Phone number is bound to a text field with 50 characters.) I've deliberately
left the Format and mask field empty in the Table datasheet view to avoid
confusion.

The format field is set to "\(000\)\ 000-0000"
The mask field is set to !\(000") "000\-0000;;_

I've tested this with a blank database with a simple form. The mask will
force the user to fill the field correctly. As expected, the data is stored,
at least as viewed using the table datasheet view, with no formatting. As in:
3333333333.

Display of this data on the form is 3333333333 unless the field has the
focus. In which case the form will display the data as (333) 333-3333. If the
form is set to a new record, the field is blank until it received the focus,
then the mask appears to force correct entry.

Does this sound normal. It seems to me that if there is no data in the
field, the mask should be visible at all times even if the field is empty and
when a viewer is looking at and working with other data on a form he should
not have to click on a field to see the format or the mask.

Ultimately this field has to be connected to a table whose phone numbers are
already in the form 333.333.3333 and the user wants to see (333) 333-3333. I
suspect I will have to convert the text column to the form 3333333333 in the
table once I get this format and mask working in a reasonnable way.

Incidentally, data will display correctly if the data is stored in the table
in the form (333) 333-3333. However, the only way this format can be stored
in the table is for the user to type in all characters and spaces without the
use of a mask. If a mask is used it will store it with no extra characters as
mentioned previously.

I cant believe access works this way. I must be doing something wrong and I
suspect there is some configuration setting that prevents this from working
in a reasonnable way.

Thanks in advance for your comments.
 
D

Douglas J. Steele

Yes, the mask will only be visible when the field has focus.

You can have the data stored as (333) 333-3333 if you change your mask to
!\(000") "000\-0000;0;_

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)
 
G

Guest

Thanks Doug,

That resolves the issues as long as the format does not need to be changed.
If that happens I guess the data will have to be convered as it does now.

I suppose there is no way for a Format property to cause a field to display
the correct format even if the field does not have the focus. This certainly
works with dates. If for instance the Medium Date built in format is used. It
also works if the format field is dd-mm-yyyy. The data is stored unformatted
but it appears formatted even if the field does not have the focus.
 

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