Results 1 to 4 of 4
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185

    Input Masks

    Good Morning!
    I have a form, where I am entering information. I need to insure, CAPS are used in this database, for everthing.
    I tried the below Module I found on line, but can not seem to get it to work.

    Can someone help me out? I'm not very familiar with modules, so am unsure of how this is supposed to be written, nor what to put in the keypress event on the fields in the form where needed.

    Thanks

    I was putting in Keypress, ConvertToCaps KeyAscii as was instructed. but Access says it doesn't know the macro, group, etc... not sure. It's name is saved as mdlTextStuff, but I didn't think that mattered. The code is below. Thanks, again!




    Public Sub ConvertToCaps(KeyAscii As Integer)
    ' Converts text typed into control to upper case

    Dim strCharacter As String

    ' Convert ANSI value to character string.
    strCharacter = Chr(KeyAscii)


    ' Convert character to upper case, then to ANSI value.
    KeyAscii = Asc(UCase(strCharacter))

    End Sub

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    The instruction is to put the subroutine "ConvertToCaps" in the "On Key Press" Event of your Textbox, Combobox, ..., etc.

    http://msdn.microsoft.com/en-us/libr.../ff197089.aspx

    Alternative is to use "UCase" function in "After Update" event. "TextBox1" is a text box on form.

    Public Sub TextBox1_AfterUpdate()
    'Convert to Upper case
    Me.TextBox1 = UCase(Me.TextBox1)
    End Sub

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    I'd tend to do the second method, posted by lfpm062010. You don't want to be interrupting the user's every keystroke with a translation, which will slow down data entry a bit, and look a little "flickery", so translating the whole item to upper case afterwards, once, is preferable.

    Technically, it should probably be in the "BeforeUpdate" event, since in theory you should be checking the data and fixing it before allowing it to ever be written to the database, but the AfterUpdate event will have the same effect, albeit with two physical writes to the record, one before, and one after the translation. If you had a thousand people banging on the application, and needed to squeeze every millisecond out of the process, then you'd do "BeforeUpdate".

    And you'd write the application in something other than Access.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Dal Jeanis View Post

    ...I'd tend to do the second method...
    I agree with that, for the stated reason.

    Quote Originally Posted by Dal Jeanis View Post

    ...Technically, it should probably be in the "BeforeUpdate" event...
    Can't do that; the Access Gnomes have fits if you try to change a Control's Value in its BeforeUpdate event, even if you're simply changing the Case of the Value.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Question on input masks
    By MikeFanch in forum Access
    Replies: 2
    Last Post: 05-23-2014, 09:03 PM
  2. Input Masks
    By ICTTeacher in forum Database Design
    Replies: 1
    Last Post: 11-07-2013, 10:08 AM
  3. Validation and Input masks
    By Santi in forum Access
    Replies: 3
    Last Post: 03-26-2009, 10:53 AM
  4. can a field have 2 different input masks
    By cjamps in forum Database Design
    Replies: 1
    Last Post: 03-21-2009, 02:47 PM
  5. Database Form Input Masks
    By scartmell in forum Forms
    Replies: 1
    Last Post: 08-12-2008, 01:20 PM

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