Can MS Access change text to all CAPS as you type it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DanicaDear
    Contributor
    • Sep 2009
    • 269

    Can MS Access change text to all CAPS as you type it?

    I want to use all caps in a database. I desire to show all caps AS YOU TYPE regardless of how the keyboard/caps lock is set. I tried to format my form field [CUST_LAST_NAME] with an on-click event…and this is the code I am trying to use (which I found on the internet while researching this).
    Code:
    Private Sub ChangetoUpperCase(KeyAscii As Integer)
    If KeyAscii >= 97 And KeyAscii <= 122 Then
    KeyAscii = (KeyAscii - 32)
    End If
    End Sub
    I have tried to put this code in my code builder in many different ways…I’m not EXACTLY sure how to do it. Here is the text from my VBA screen:
    Code:
    Option Compare Database
    
    Private Sub Command81_Click()
    
    End Sub
    
    
    Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
    **I tried to put the code here, along with after the end sub, along with replacing the first private sub, etc etc etc.
    End Sub
    **There is more stuff below but access had it in there automatically so I’m assuming I can ignore it.**
    How can I get this to work…or what’s another method to accomplish my goals?
    I am aware of the UCASE function but I’d really like to see all caps as I type, not after event. This is my first experience with both Access and VBA, so take it easy on me if possible. Thanks in advance!
    Last edited by NeoPa; Oct 8 '09, 07:43 PM. Reason: Please use the [CODE] tags provided.
  • JennDub
    New Member
    • Oct 2009
    • 5

    #2
    DanicaDear,
    You could use an input mask such as ">aaaaa" in the text box "Input Mask" property. You would need to continue the a's above for as many characters as you would like to allow the user to enter.

    ~JennDub

    Comment

    • DanicaDear
      Contributor
      • Sep 2009
      • 269

      #3
      The input mask requires that they enter info a certain way (ie. press the caps lock key). I don't want them to have to do that. I know it's just pressing a key...not that difficult....bu t I'm designing a program to match what they currently use and I want the entry to be the exact same. Currently, it doesn't matter how they type in the info, it appears and stores as caps. Thanks JennDub for your reply. Any more suggestions?

      Comment

      • ajalwaysus
        Recognized Expert Contributor
        • Jul 2009
        • 266

        #4
        DanicaDear,

        What JennDub suggests does work, the input mask upper cases all key strokes, there is no need to hit the Caps Lock key. Input mask is not a validation tool, it's a mask.

        -AJ

        Comment

        • JennDub
          New Member
          • Oct 2009
          • 5

          #5
          The input mask actually upgrades any text entered into all caps using the ">" symbol. It would eliminate the need for a user to click the "Caps Lock".

          Comment

          • DanicaDear
            Contributor
            • Sep 2009
            • 269

            #6
            Would you recommend that I do this on the FORMS or at the TABLE?
            Thanks guys!

            Comment

            • DanicaDear
              Contributor
              • Sep 2009
              • 269

              #7
              Okay...I get it now. I have tried this...If I do it in FORMS the user sees the CAPS change as he types. If I do it in tables, it stores it as CAPS but the user might think he's entering in lower case, if he is. So I'll do it in FORMS since this sends it to the table in caps. I'm not crazy about that underline that it puts in the form...but I can quickly get over that. You guys are AWESOME. THANK YOU SO MUCH!!! I am VERY appreciative.

              Comment

              • ajalwaysus
                Recognized Expert Contributor
                • Jul 2009
                • 266

                #8
                Nice quick resolution JennDub.

                DanicaDear,
                I agree that input masks are not the best thing, I honestly avoid it wherever I can. In regards to where to put it, I would recommend the table, and then any bound fields would inherit that input mask, and then you would also need to add the input mask to all unbound fields that relate to that field.

                -AJ

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32656

                  #9
                  If the underline is a problem then you could use the event you attempted.
                  Code:
                  Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
                      Select Case KeyAscii
                      Case Asc("a") To Asc("z")
                          KeyAscii = KeyAscii + Asc("A") - Asc("a")
                      End Select
                  End Sub

                  Comment

                  • ajalwaysus
                    Recognized Expert Contributor
                    • Jul 2009
                    • 266

                    #10
                    Now this is a nice piece of code, if I only I came across this in my college days, I may have been able to convince my professor to allow us to use this instead of the annoying input mask provided out of the box.

                    -AJ

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32656

                      #11
                      Thanks AJ, but it's fundamentally just the code Danica posted (albeit hers wasn't in the correct procedure and possibly I tarted it up a little). I appreciate the comment though :)

                      Comment

                      • DanicaDear
                        Contributor
                        • Sep 2009
                        • 269

                        #12
                        NeoPa,
                        Where should I put your code? I'm not seeing a place in the tables property box to put it.

                        Also, if my forms are already built and I place the code in the table as recommended by this post, will the forms pick up on the All Caps or will I need to do more work to the forms?

                        Right now I have >CCCC... everywhere so I have some work to do. :)

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32656

                          #13
                          This code is Form specific Danica. Tables have the facility to set up various properties, including a mask, but not to run code on events. This can be done in SQL Server using Triggers, but not in Access I'm afraid. This code would go into a data-entry (and modification) type form.

                          Comment

                          • MrDeej
                            New Member
                            • Apr 2007
                            • 157

                            #14
                            Dont make this so hard

                            me.textbox afterupdate
                            Code:
                            me.textbox = ucase(me.textbox)
                            Last edited by NeoPa; Nov 9 '09, 04:09 PM. Reason: Please use the [CODE] tags provided.

                            Comment

                            • topher23
                              Recognized Expert New Member
                              • Oct 2008
                              • 234

                              #15
                              Originally posted by NeoPa
                              If the underline is a problem then you could use the event you attempted.
                              Code:
                              Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
                                  Select Case KeyAscii
                                  Case Asc("a") To Asc("z")
                                      KeyAscii = KeyAscii + Asc("A") - Asc("a")
                                  End Select
                              End Sub
                              Amazing how things come around. Back in the ancient of days when I was building text-based apps in IBM-BASIC, I used this method to uppercase each keystroke. Using Access, I decided it really didn't matter if each keystroke translated to uppercase and just used the input mask or
                              Code:
                              Me.txtControl.Text=UCase(Me.txtControl.Text)
                              .

                              Comment

                              Working...