Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Member
 
Join Date: Sep 2009
Location: Alabama
Posts: 101
#1: Oct 8 '09
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).
Expand|Select|Wrap|Line Numbers
  1. Private Sub ChangetoUpperCase(KeyAscii As Integer)
  2. If KeyAscii >= 97 And KeyAscii <= 122 Then
  3. KeyAscii = (KeyAscii - 32)
  4. End If
  5. 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:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Command81_Click()
  4.  
  5. End Sub
  6.  
  7.  
  8. Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
  9. **I tried to put the code here, along with after the end sub, along with replacing the first private sub, etc etc etc.
  10. End Sub
  11. **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!
best answer - posted by NeoPa
If the underline is a problem then you could use the event you attempted.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
  2.     Select Case KeyAscii
  3.     Case Asc("a") To Asc("z")
  4.         KeyAscii = KeyAscii + Asc("A") - Asc("a")
  5.     End Select
  6. End Sub

Newbie
 
Join Date: Oct 2009
Location: Virginia
Posts: 5
#2: Oct 8 '09

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


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
Member
 
Join Date: Sep 2009
Location: Alabama
Posts: 101
#3: Oct 8 '09

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


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....but 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?
Expert
 
Join Date: Jul 2009
Location: KY
Posts: 253
#4: Oct 8 '09

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


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
Newbie
 
Join Date: Oct 2009
Location: Virginia
Posts: 5
#5: Oct 8 '09

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


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".
Member
 
Join Date: Sep 2009
Location: Alabama
Posts: 101
#6: Oct 8 '09

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


Would you recommend that I do this on the FORMS or at the TABLE?
Thanks guys!
Member
 
Join Date: Sep 2009
Location: Alabama
Posts: 101
#7: Oct 8 '09

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


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.
Expert
 
Join Date: Jul 2009
Location: KY
Posts: 253
#8: Oct 8 '09

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


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
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,747
#9: Oct 8 '09

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


If the underline is a problem then you could use the event you attempted.
Expand|Select|Wrap|Line Numbers
  1. Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
  2.     Select Case KeyAscii
  3.     Case Asc("a") To Asc("z")
  4.         KeyAscii = KeyAscii + Asc("A") - Asc("a")
  5.     End Select
  6. End Sub
Expert
 
Join Date: Jul 2009
Location: KY
Posts: 253
#10: Oct 8 '09

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


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
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,747
#11: Oct 8 '09

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


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 :)
Member
 
Join Date: Sep 2009
Location: Alabama
Posts: 101
#12: 4 Weeks Ago

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


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. :)
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,747
#13: 4 Weeks Ago

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


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.
Member
 
Join Date: Apr 2007
Location: Norway
Posts: 95
#14: 2 Weeks Ago

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


Dont make this so hard

me.textbox afterupdate
Expand|Select|Wrap|Line Numbers
  1. me.textbox = ucase(me.textbox)
Expert
 
Join Date: Oct 2008
Location: Cedar City, Utah, USA
Posts: 100
#15: 2 Weeks Ago

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


Quote:

Originally Posted by NeoPa View Post

If the underline is a problem then you could use the event you attempted.

Expand|Select|Wrap|Line Numbers
  1. Private Sub CUST_LAST_NAME_KeyPress(KeyAscii As Integer)
  2.     Select Case KeyAscii
  3.     Case Asc("a") To Asc("z")
  4.         KeyAscii = KeyAscii + Asc("A") - Asc("a")
  5.     End Select
  6. 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
Expand|Select|Wrap|Line Numbers
  1. Me.txtControl.Text=UCase(Me.txtControl.Text)
.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,747
#16: 2 Weeks Ago

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


Quote:

Originally Posted by MrDeej View Post

Dont make this so hard

me.textbox afterupdate

Expand|Select|Wrap|Line Numbers
  1. me.textbox = ucase(me.textbox)

For most purposes yes.

If you review post #7 though, you will see why this is not recommended in this case as the change only occurs after all characters have been entered.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,747
#17: 2 Weeks Ago

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


Quote:

Originally Posted by topher23 View Post

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

Expand|Select|Wrap|Line Numbers
  1. Me.txtControl.Text=UCase(Me.txtControl.Text)
.

Wow. I'm guessing that was the first basic provided by Microsoft for IBM that came built in with the IBM PC. Correct me if I'm wrong.

And yes, of course, in most cases UCase() would be fine, but the OP has specified earlier that she doesn't want the operator getting confused and/or having to worry about the CAPS LOCK key and this functionality is still available for such requirements.
Member
 
Join Date: Sep 2009
Location: Alabama
Posts: 101
#18: 2 Weeks Ago

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


Yes, NeoPa is correct. The users of the DB aren't computer savvy and I don't want any confusion for them. If they see lower caps, they might freak out. LOL.

I do appreciate your offerings of simple solutions, topher23 and MrDeej!
Expert
 
Join Date: Oct 2008
Location: Cedar City, Utah, USA
Posts: 100
#19: 2 Weeks Ago

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


Quote:

Originally Posted by NeoPa View Post

And yes, of course, in most cases UCase() would be fine, but the OP has specified earlier that she doesn't want the operator getting confused and/or having to worry about the CAPS LOCK key and this functionality is still available for such requirements.

I caught that, I was just making an observation. I completely understand confused operators - I work in manufacturing.

Quote:

Originally Posted by NeoPa View Post

Wow. I'm guessing that was the first basic provided by Microsoft for IBM that came built in with the IBM PC. Correct me if I'm wrong.

Yep, that's it. My Dad brought home a used PC-XT after I blew up my (technically his) TI-99/4A. I liked TI-BASIC/Extended BASIC a lot better than IBM-BASIC/BASICA, though.
Reply