DEFAULT AREA CODE IN PHONE NUMBER INPUT MASK

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I make only part of a field default. I want the area code in a phone number to default?
 
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.
 
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
 
Back
Top