Default Phone Number

  • Thread starter Thread starter Don Garry
  • Start date Start date
D

Don Garry

Hello, I believe this is a pretty simple question but I can't seem to find
an answer in the help file.

If I have a field called PhoneNumber and I want the default to show the area
code like:
(250) 999-9999

What syntax do I use in the field default property ??

I'd sure appreciate a response if you could.
 
I woould suggest an InputMask rather than DefaultValue if
you want the phone number to be entered into a certain
format.

Check Access Help on InputMask Property.

HTH
Van T. Dinh
MVP (Access)
 
Don, If it is always going to be (205) you could use an input mask like so making sure your
PhoneNumber field is Text:
Input Mask = !"(205) "000\-0000;0;_
This method will not allow you to change the areacode portion.

If you want to be able to change it change the mask like so:
\(000") "000\-0000;0;_
Now set the default to 205

Another thing you could do is split the field up into AreaCode an PhoneNumber. Set the area code up
as text and default value = (205).

Hope this helps!
 
Hi Don,

I'll differ from Van on this: input masks are only suitable for domains
where the format is always the same, and this is not always true of
telephone numbers.

The "(999) 999-9999" pattern works for most numbers in North America as
long as you can convert "numbers" like "1-800-FREE-SEX" into the
all-number equivalent (let's see if that triggers the spam filters!).
But it won't work for numbers like 911 or for international numbers.
Many other countries are even less consistent.

So IMHO it's best not to use an input mask, but just to set a default
value containing the area code followed by a space "(250) ".

To make the best use of this you need to ensure that the insertion point
goes to the end of the field when the user moves to that field. You can
do this for the database as a whole by going to Tools|Options|Keyboard,
or you can do it by using VBA code to manipulate the SelStart property
of the textbox in its Enter event procedure.
 
Hi John

I agree tha telephone numbers vary too much to for InputMask to be used in
general. I never use InputMask for telephone numbers.

However, I don't like setting a default / dummy telephone number, either
since if the user doesn't enter a valid number, I end up with the dummy
number in the database.

--
HTH
Van T. Dinh
MVP (Access)
 
I agree tha telephone numbers vary too much to for InputMask to be used in
general. I never use InputMask for telephone numbers.

However, I don't like setting a default / dummy telephone number, either
since if the user doesn't enter a valid number, I end up with the dummy
number in the database.

True. For an "incomplete default value" like this I have used validation
code that checks whether the default value has been changed - i.e.
whether a number has been entered - and if not deletes the default.
 
Back
Top