Phone Default Value

emillard

New member
Local time
Today, 21:37
Joined
Feb 7, 2001
Messages
9
I have been pulling my hair out with this one. I have three phone number fields - home, work, and cellular.

My goal is to accommodate the user when entering the phone, but also to allow for exceptions. I have set up the three phone fields with:
input masks: "("000")"000\-0000
default value: 315
Got Focus: Me.ActiveControl.SelStart = 6
The fields are not required.

This way the when the user tabs to the field they begin to type at the exchange portion but also can as needed over-ride the default for an out-of-area area code.

Hope this makes sense so far …

This all works great when the enter a phone number, the problem occurs when the field is left blank – the table then shows the field as ( ) -315 . I have looked all over to find a way of only entering the default value when the phone field is not blank.

Any help with the existing setup of the fields or possible resolves would be greatly appreciated. I played around some with allow zero-length, validation rules after update, and some others but to no avail.
Thanks
Emillard
 
Private Sub Phone_GotFocus()
If IsNull(Me.Phone) Then Me.Phone = "315"
Me.ActiveControl.SelStart = 6

End Sub

Private Sub Phone_LostFocus()
If Me.Phone = "315" Then Me.Phone = Null
End Sub


Try the above code for your phone field and get rid of the default value
 
dan-cat

Thank you so much - I'm somewhat a newbie and mostly learned from trial and error when it comes to databases - this one is for volunteers to use so I want it to be as user friendly as possible. This forum has been an incredible help with solving some prior issues. I just couldn't get this one worked out. Your code worked like a charm! Thanks again.
Emillard
 
sorry, i know this is an old post, but i came across it cuz i'm having the same issue. when i try the same code, the area code is ending up at the END of the input mask instead of at the beginning. :( Could someone give me some guidance in this?

DJ
 

Users who are viewing this thread

Back
Top Bottom