开发者

Phone Number Mask - Internationals

开发者 https://www.devze.com 2023-03-28 00:44 出处:网络
My Problem My Customer Contact Database has a variety of customers from around the world in it, and this causes some problems for my telephone numbers - because of the different methods of formating

My Problem

My Customer Contact Database has a variety of customers from around the world in it, and this causes some problems for my telephone numbers - because of the different methods of formating in other countries. So my question is, firstly since I also have a country field - Is it possible to have the type of mask change based of what country the customer is in?

Example:

In Can开发者_开发技巧ada -> (xxx)xxx-xxxx
In Australia -> (xx) xxxx-xxxx
In South Africa -> xx (x) xx-xxx-xxxx

x - A placeholder for numbers

Would this be possible?


Hans mentioned he couldn't get the Input Mask to change at runtime - I haven't seen his previous answer, but this seems to work for me. My form has a drop-down for country (cmbCountry), and a text box for phone. My combo box (cmbCountry) is tied to a table (Row Source=SELECT [_ masks].Country, [_ masks].Mask FROM [_ masks];). The "masks" field is hidden by having its' width be zero.

I've also bound the form to a table which stores the countries and phone numbers. When the country changes, or the record changes, I change the ListIndex property.

FYI - I did not give the Input Mask any default value in Design mode.

@HansUp, is this similar to what you had already? Sorry if I'm re-answering the question in the same way.

In the code behind the form:

Private Sub cmbCountry_Change()
    Dim sMask
    If cmbCountry.ListIndex > -1 Then
        sMask = cmbCountry.Column(1, cmbCountry.ListIndex)
        tbPhone.InputMask = sMask
    End If
End Sub

Private Sub Form_Current()
    cmbCountry_Change
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消