View Full Version : Forcing capitalization


superrob5
06-30-2003, 07:46 AM
Is there away to foce capitalization on a person name even if there for example
SMITH
SMITH /JONES

IgorB
06-30-2003, 07:55 AM
Create query
UPDATE YourTableName SET PersonName = UCase(PersonName)

superrob5
06-30-2003, 08:17 AM
I am talking about when entering info not viewing it.

dcx693
06-30-2003, 09:59 AM
As far as I know, there's no automatic way to handle it when entering data, you have to write your own routines.

It's not too bad conceptually. Just use the KeyPress event of the control you are working with. Have it check each keystroke and, if it's ascii value is between 97 and 122, it's a lowercase letter from a to z. Just use code to subtract 32 from it to get to the capital letter equivalents. Here's some sample code:

Private Sub txtName_KeyPress(KeyAscii As Integer)
&nbsp;If KeyAscii >= 97 And KeyAscii <= 122 Then
&nbsp;&nbsp;DoCmd.CancelEvent
&nbsp;&nbsp;SendKeys CStr(Chr(KeyAscii - 32))
&nbsp;End If
End Sub

daveUK
06-30-2003, 11:50 AM
On the KeyPress event of the texbox enter the following code;

KeyAscii = Asc(UCase(Chr$(KeyAscii)))

Dave