My Assistant
![]() ![]() |
|
|
Jan 11 2008, 12:23 AM
Post
#1
|
|
|
UtterAccess Addict Posts: 159 |
Hi
I am working on an employee database. The employees are scattered over the world. As you know, there are several telephone formats. When I enter a country, I want the db to configure a phone format to that country. So far, no luck. Help |
|
|
|
Jan 11 2008, 02:54 AM
Post
#2
|
|
|
UtterAccess Ruler Posts: 1,150 From: Elizabethtown, KY |
If you're speaking of inputmasks, you could save the different masks to a table and associate each record (or multiple records) to a specific country. An example of the table structure could be:
tblTelephoneMask PhoneMaskID (PK) CountryID (FK) TelephoneMask (String) The TelephoneMask field would be made up of character just like the InputMask property of the field you're saving the data to. Remove any inputmask from the field and apply the input mask to the form's Telephone Entry textbox control after the country is selected: CODE Private Sub cboCountry_AfterUpdate()
Me.txtTelephone.InputMask = Nz(Dlookup("[TelephoneMask]", "tblTelephoneMask", "[CountryID]=" & Me.cboCountry) End Sub |
|
|
|
Jan 11 2008, 03:03 AM
Post
#3
|
|
|
UtterAccess VIP Posts: 20,210 From: Colorado |
in your table with countries, add -->
PhoneMask, text in the data, if the mask has a quote, then use 2 since it will be assigned through code. Example: CODE !\(999"") ""000\-0000;0;_ you are going to want to be able to override the automatic mask, so create the following checkbox: chkUseMask put this code behind your form: CODE Private Sub Form_Load() 'assume you want the input mask to be used Me.chkUseMask = True End Sub Private Sub Form_AfterUpdate() 'clear the input mask after a record is updated 'store symbols Me.Phone.InputMask = "" End Sub Private Function SetInputMask() 'do this if you want the country to default to the US If IsNull(Me.Ctry) Then Me.Ctry = "US" Me.Phone.InputMask = GetPhoneInputMask() End Function Private Function GetPhoneInputMask() As String If Nz(Me.chkUseMask, False) Then If Not IsNull(Me.Ctry) Then 'or whatever column the input mask is in the country combo box GetPhoneInputMask = Nz(Me.Ctry.Column(3), "") Else GetPhoneInputMask = "" End If Else GetPhoneInputMask = "" End If End Function on the Ctry AfterUpdate event --> = SetInputMask() on the form BeforeInsert event --> =SetInputMask() |
|
|
|
Jan 11 2008, 03:05 AM
Post
#4
|
|
|
UtterAccess VIP Posts: 20,210 From: Colorado |
oh, another procedure for the code behind your form -- to remove or add the mask if you change chkUseMask
CODE Private Sub chkUseMask_AfterUpdate()
If Not Me.chkUseMask Then Me.Phone.InputMask = "" Else SetInputMask End If End Sub |
|
|
|
Jan 11 2008, 03:09 AM
Post
#5
|
|
|
UtterAccess VIP Posts: 20,210 From: Colorado |
Another thing to consider is giving users a way to paste phone numbers (if there is an InputMask, the number has to be stripped of all symbols before pasting) -- when you get all the basic stuff working and want to know how to do that, if at that point, just ask
|
|
|
|
Feb 9 2008, 12:32 PM
Post
#6
|
|
|
UtterAccess Addict Posts: 159 |
OK. Now the follow-on question
Is there a site or location where I can find the formats of all countries? |
|
|
|
Feb 9 2008, 12:44 PM
Post
#7
|
|
|
UtterAccess VIP Posts: 20,210 From: Colorado |
not that I know of -- you can google embassies (for instance) in various countries and use that information for masks -- but realize that not all countries are consistent ...
In my database, I have an override for the mask. I also have a place to click if the user wants to paste a phone number that already has symbols and either correct it for the mask or leave it as is Edited by: strive4peace2008 on Sat Feb 9 12:44:58 EST 2008. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 03:10 AM |