DEFAULT AREA CODE IN PHONE NUMBER INPUT MASK

L

Laurie

How can I make only part of a field default. I want the area code in a phone number to default?
 
J

John Vinson

How can I make only part of a field default. I want the area code in a phone number to default?

This isn't easily done in a Table - you can set the default to (say)
2080000000 but then you'll have to overtype the zeros, risking error.

In a Form you can set the Default to (say)

(208)

with an Input Mask of (000)000-0000

You can then put the following code in the GotFocus event of the
textbox:

Private Sub txtPhone_GotFocus()
Me!txtPhone.SelStart = 6
Me!txtPhone.SelLength = 8
End Sub

This will fill in the area code and leave the insertion point at the
next digit. You can back up and overtype the area code if need be.
 
T

Tim Ferguson

How can I make only part of a field default.

If you think the area code is a different piece of information from the
rest of the number, then it ought to be in its own field. Then it becomes
easy to make the defaultvalue = "079" or whatever.

HTH


Tim F
 

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