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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Question: Convert to Uppercase 5

Status
Not open for further replies.

mkallover

Programmer
Feb 6, 2008
88
0
0
US
I have a bound form with a user ID field that I want to be all uppercase. What would be the best event to attach my conversion code?

The form that is used to add a user is used in a lot of different ways. Sometimes they'll be adding a user from scratch and other times they'll just be adding information like email addresses or phone numbers.

Would it be best to put it on the Save button?
 
If you just want the ID to be in uppercase, open the table in design view, click on the ID field and in the properties on the bottom where it says Format, put a >
 
How are ya mkallover . . .

VBA has two functions available, [blue]StrConv[/blue] & [blue]UCase[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks fneily, I'll give that a go.

AceMan, I know how to do it, I was just wondering what the best event might be for doing it.
 
mkallover . . .

Be aware: [blue]format[/blue] is a display function and doesn't change the actual underlying data!

If you have
[blue]aceman1[/blue]
Format shows
[blue]AceMan1[/blue]
However
[blue]aceman1[/blue]
is what's saved to the table.

If you desire to save in upper case, you'll have to make it so.


Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
The actual data in my tables, when typed in lowercase, were saved as upper when I use > on the format line in the table design view.
 
Howdy fneily . . .

Since your sure data was saved in upper case, [purple]the only way to tell[/purple] is remove the [blue]>[/blue] in the format property and then tell me what you get!

I say again . . . [blue]Format[/blue] is a display function only! . . . doesn't affect data! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I did a little experiment. Aceman is right, as soon as the ">" is taken out of the table design, you will see the string in whatever case you typed it in as.

 
To answer your question mkallover.

I would put the code in the after update event of the (textbox) CONTROL

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Code:
Function testCase(MyStr As Variant) As Variant
    On Error GoTo testCaseError
    testCase = Asc(Left(MyStr, 1))
testCaseEnd:
         Exit Function
testCaseError:
         MsgBox Error$
         Resume testCaseEnd
End Function
I place the ">" in my table format.
I use the function in a query.
if I type in an "a" in a field I get 97
if I type in an "A" I get 65

 
My experiment was:

1. Change Format property to ">"
2. Open table, type in "aBcD", when I tab off it automatically formats it as "ABCD"
3. Go back to table design, remove ">" from the Format property
4. Open table, it now displays "aBcD", just what I typed in

Surely that is enough empirical evidence, not just "opinion"?


 
I was thinking couldn't you do something as simple as this ?

Code:
Private Sub Text0_LostFocus()
Text0.Value = UCase(Text0.Value)
End Sub

Just a thought.


-Me-> All I want is the chance to prove money won't make me happy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top