473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Input mask change using combobox selection

Hello All,
I have the folowing case.
table Countries: Country_ID, Country_Name, PHCODE
In a form i have the folowing fields:
SCountry
SCPhone1
SCPhone2
I want when i choose a country from the combobox Scountry
the input mask for SCPhone1 and 2 to load the PHCODE(international phone code) form the Countryes table.
I'm sure it is easy but i can seems to make it work.
Oct 25 '10 #1

✓ answered by Kaloyan Krumov

I have managed to do it:
Hope this code will help someone else as i found alot of q about such thing and no answers:
Expand|Select|Wrap|Line Numbers
  1. Private Sub SCCountry_AfterUpdate()
  2. Dim mask As String
  3.  
  4. mask = ""
  5. mask = DLookup("PHCODE", "Countries", "Countryid='" & Me.SCCountry & "'")
  6.  
  7. SCPhone1.InputMask = "(+" & Replace(Replace(mask, "9", "\9"), "0", "\0") & ")##########"
  8. SCPhone2.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  9. SCMPhone3.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  10. SCFAX1.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  11. SCFAX2.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  12. SCMail.InputMask = "#############" & "@" & "#################" & "." & "###"
  13.  
  14. End Sub
  15.  

3 2657
I used DlookUp but i get error message: 'country code value' runtime error 2471
Expand|Select|Wrap|Line Numbers
  1. Private Sub SCCountry_AfterUpdate()
  2. Dim mask As String
  3. mask = DLookup("PHCODE", "Countries", "Countryid=" & Me.Form!SCCountry)
  4. SCPhone1.InputMask = "("& "+" & mask & ")"
  5. End Sub 
  6.  
if i remove "Countryid=" & form dlookup it works, but i always returns (+35_)
wich is the part of the phone code for Bulgaria
Oct 25 '10 #2
Well i did it:
Syntax error
Expand|Select|Wrap|Line Numbers
  1. Dim mask As String
  2. mask = ""
  3. mask = DLookup("PHCODE", "Countries", "Countryid='" & Me.SCCountry & "'")
  4. SCPhone1.InputMask = "(" & "+" & mask & ")"
  5.  
Now another problem if the phone code contains 9 or 0 guess how the input mask interpret it _. If anyone has a suggestion pleases post.
TX
Oct 25 '10 #3
I have managed to do it:
Hope this code will help someone else as i found alot of q about such thing and no answers:
Expand|Select|Wrap|Line Numbers
  1. Private Sub SCCountry_AfterUpdate()
  2. Dim mask As String
  3.  
  4. mask = ""
  5. mask = DLookup("PHCODE", "Countries", "Countryid='" & Me.SCCountry & "'")
  6.  
  7. SCPhone1.InputMask = "(+" & Replace(Replace(mask, "9", "\9"), "0", "\0") & ")##########"
  8. SCPhone2.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  9. SCMPhone3.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  10. SCFAX1.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  11. SCFAX2.InputMask = "(+\" & Replace(Replace(mask, "9", "\9"), "0", "\0") & "\)##########"
  12. SCMail.InputMask = "#############" & "@" & "#################" & "." & "###"
  13.  
  14. End Sub
  15.  
Oct 25 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: dude | last post by:
hello how would i make an input mask that only makes the first letter a capitol one? i've been playing around and testing various masks, also tried the wizard, but i've had no luck. could...
2
by: johnp | last post by:
Hi, Our Tech department updated users to Office 2003 this week. Now the input mask in one of the applications is showing up as: (###) ###-### The input mask wizard works correctly when I...
7
by: F. Michael Miller | last post by:
I have a db with Access front end, sql back, linked tables. I need to be able to change input masks at the table level in code. Any ideas? Thanks!
3
by: AA Arens | last post by:
When I want the first character of a field to be Uppercased, I need to make an input mask, like >L< followed by ??????? for example. But this mask creates ____ in an unfilled field, which I don't...
1
by: Jon Peck | last post by:
I'm largely self-taught (so hardly an expert) in Access 2002. I'm wondering if it's possible to have a conditional input mask on a field in a form. My database keeps track of people who register...
0
by: jmarr02s | last post by:
I am using the following input mask 00\-A0000000. The values entered using this input mask will have one of the following formats: 14-X1234567 OR 14-1234. What must I change on the textbox...
2
by: jmarr02s | last post by:
I need my Date field to possess the following format: Jan-05-1999 How do I change the Date Format/Input Mask to accomplish this? Thanks! John
1
by: Doug | last post by:
Hi, I created a short date field. The format is dd/mm/yyyy when displayed. The input mask is set to 99/99/00;0 (default, I didn't type anything). If I edit an existing date, say change...
4
by: Mtek | last post by:
Hi, We have a combo box on our page, which gets populated via a MySQL Query in PHP. What we want to do is to print the values on the page in a table that correspond the to selection from the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.