Results 1 to 3 of 3
  1. #1
    judicial85 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Waterloo, ON
    Posts
    2

    Input Mask Macro

    Hello!

    I am currently playing with a database that stores contact information for both Canadian and USA addresses. Problem is the default one I downloaded has the Form's input mask set to ">L0L\ 0L0;;_"!

    My plan was to make a quick marco that, upon updating [Country/Region] = "USA" would change the input mask to "00000\-9999;;_"

    I think my problem is with the new 2010 setup: Access doesn't recognize either "Me![ZIP/Postal Code].InputMask" or "[ZIP/Postal Code].[InputMask]" in the "Control Name" field under "SetProperty". How do I use the new ~VBA interface to change a Form Control's input mask? (via "Build Macro")

    Thanks for any help!
    Bryan



    PS - If I want to write a form macro as in 2007, can I avoid this awkward Wizard-like setup? (I used to like "Build Macro" better in 2007)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't use macros, only VBA. Also don't use wizards.

    In the AfterUpdate event property select [Event Procedure]. Then double click the ellipses (...) to go to the VBA procedure. Type code.

    Me.[ZIP/Postal Code].InputMask = "00000\-9999;;_"


    Using dot instead of ! will provoke VBA intellisense popup tips as you type. I recommed naming the control like tbxCode and use that name in the code.

    It is advised to avoid spaces, special characters, punctuation (underscore is exception) in any names or reserved words as names. If any used, must enclose in [].
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    judicial85 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Waterloo, ON
    Posts
    2
    Thanks for the reply! An informative read! I understand the point about spaces, but have yet to remove them from all the template's fields.

    Right after posting, I successfully used VBA to achieve the switch with the OnCurrent box. Fortunately, I didn't have to translate (to VBA) or add to any of the template's macros, which could have been frustrating.

    ~Bryan~

    Code:
    Private Sub Country_Region_AfterUpdate()
        If Me![Country/Region].Value = "US" Or Me![Country/Region].Value = "USa" Or Me![Country/Region].Value = "Usa" Or Me![Country/Region].Value = "usa" Or Me![Country/Region].Value = "United States" _
        Or Me![Country/Region].Value = "United States of America" Or Me![Country/Region].Value = "America" Then
            Me![Country/Region].Value = "USA"
        End If
        
        If Me![Country/Region].Value = "USA" Then
            Me![ZIP/Postal Code].InputMask = "00000\-9999;0;_"
        ElseIf Me![Country/Region].Value = "Canada" Then
            Me![ZIP/Postal Code].InputMask = ">L0L\ 0L0;;_"
        End If
    End Sub
    
    Private Sub Form_Current()
        
            If [Forms]![Contact Details]![Country/Region].Value = "USA" Then
                [Forms]![Contact Details]![ZIP/Postal Code].InputMask = "00000\-9999;0;_"
            ElseIf [Forms]![Contact Details]![Country/Region].Value = "Canada" Then
                [Forms]![Contact Details]![ZIP/Postal Code].InputMask = ">L0L\ 0L0;;_"
            End If
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Input Mask Issue
    By bakkouz in forum Forms
    Replies: 2
    Last Post: 10-07-2011, 08:27 AM
  2. Replies: 4
    Last Post: 10-31-2010, 10:35 AM
  3. Phone Input Mask issue
    By Huddle in forum Forms
    Replies: 4
    Last Post: 08-13-2010, 03:02 PM
  4. day of week input mask
    By jacko311 in forum Programming
    Replies: 7
    Last Post: 11-15-2009, 12:56 PM
  5. Input mask
    By doobybug in forum Access
    Replies: 2
    Last Post: 06-17-2009, 09:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums