toUpper?

bpaquette

Registered User.
Local time
Today, 09:25
Joined
Aug 13, 2003
Messages
119
ok so my users dont have any concept of uniformity throughout a database so i can't rely on them to keep all entries in all capital letters.


i dont know a damn thing about validation rules; how would i go about making 'allcaps' a validation rule? also for the existing 350+ records, is there any kind of toUpper function or whatever?




Regards,
 
Or you can try implementing a On key entered check to set the keys to upper

Or implement a format for every text field.

Regards
 
As namlian's solution use:

Private Sub Form_KeyPress(KeyAscii As Integer)
MsgBox KeyAscii
If KeyAscii > 96 And KeyAscii < 123 Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub

you must set the keypreview in the forms properties to Yes so the form catches the keypress before the controls. For records already in your database you can use an update query Ucase as Rich suggested.
 
Also, if some of the fields you refer to are peoples' names then ghudson posted a big catchall function on this thread.
 
As Rich suggested, use the Ucase function with an Update query to convert the old records to upper case.

You could use the Ucase function in the AfterUpdate event of the text box that you want the keyed text to be upper case. That will let the users key the data how ever they want and when they exit the field they will see their data converted to upper case.

Code:
'Routine is run after tbName text box is updated.
    
Private Sub tbName_AfterUpdate()
On Error GoTo Err_tbName_AfterUpdate
    
    tbName = Trim(tbName) 'remove preceeding spaces
    tbName = StrConv(tbName, vbUpperCase) 'convert to UPPER case
    
Exit_tbName_AfterUpdate:
    Exit Sub
    
Err_tbName_AfterUpdate:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_tbName_AfterUpdate
    
End Sub
HTH
 

Users who are viewing this thread

Back
Top Bottom