Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making text box all uppercase

Status
Not open for further replies.

skierm

Programmer
Jun 9, 2003
39
US
is there a way to make the value in a text box all upper case after it has lost focus.
 
You could put this code in the box's On Key Press event...

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

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Another way to do it is to go to the properties of the text box, go to the Format tab, then put an > in the Format property. If the user enters a lower case, it is forced to upper case when the user tabs or exit the text box.

Be careful though, it still stores the case as the user entered the data.

Hope this helps.
 
If you want to do this for a number of text boxes on one or more form you might use the following.

In a module put the following function:

Function CapAll(StrValue)
CapAll = UCase(StrValue)
End Function

Then in the code for your form put:

Private Sub YourTextName_AfterUpdate()
If Not IsNull([YourTextName]) Then
[YourTextName] = CapAll([YourTextName])
End If
End Sub

When you leave the text box all text will be changed to uppercase AND it will be stored as uppercase in the underlying table.

The Missinglinq




"It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
You could also put this code in the FORM's Key Press event and set the KeyPreview property to Yes for the form. Now any text box you type in will show and be store as all caps and you only have to insert the code once.

Happy coding....




ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top