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

Change data to Upper Case 1

Status
Not open for further replies.

frog40

Programmer
Oct 25, 2006
69
US
My program asks for a First Name, Middle Initial and Last name, as well as some other data. This is a one page entry form. Because of security reasons, all tool bars and menu bars have been deleted and the database is not available to the user. If the 1st name or last name have been omitted, the msg. box reminds the user to enter them and the cursor returns to the "null" value for the user to enter the name. I want all characters to be in upper case. I have set the Input Mask to > at both the database level and the form properties level. I tried UCASE(>) in the VB Code. Nothing works. I get an error message and no entry is allowed in the field. I believe the problem may be due to trying to Upper Case a null value, but how do I get around this?
 
This will do it in code
Code:
Private Sub YourFieldName_LostFocus()
  Me.YourFieldName = UCase(Me.YourFieldName)
End Sub

Or > will do it in the properties box, but it has to be placed in the Format Property, not the Input Mask property!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
How are ya frog40 . . .

In the [blue]KeyPress[/blue] event of the textboxes:
Code:
[blue]   If KeyAscii > 96 And KeyAscii < 123 Then
      KeyAscii = KeyAscii And 223
   End If[/blue]

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

Forgot to mention that with the code you can [blue]remove the input masks! . . .[/blue] The keys are converted as necessary as the user types.

Calvin.gif
See Ya! . . . . . .
 
Neat hack, Acemam1! Have y'all finally thawed out up there?

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Just a comment about all upper case versus mixed case (for example, "ROBERT" versus "Robert"). I take the opposite approach you have described, since mixed case is much easier to read than all upper case and, most important, sorting and searching in Access ignores the case. Unless you must go to all upper case because you are exporting the data to a mainframe application, I would encourage the use of mixed case to improve readability, both on the screen and on printed reports.

An additional consideration to improve readability is to use a serif type font (such as Times New Roman) for the smaller point size text (particularly 10 points or less), since the serifs improve the readability as well as the mixed case, versus the use of sans serif fonts (like Arial).

Bob
 
I really appreciate all of your suggestions. I have tried them all and I am apparently still missing something. This is the message I get.
"The Field 'MyTableName.MyFieldName' cannot contain a null value because the required property is set to True. Enter a value.

How do I enter a value (in code) so it will accept the UCase code (or whichever other code works). This is a field that must have data entered by the operator and cannot be null.
 
frog40 . . .

And just where did you place the code I gave? . . . On the event line or in the event?

I did specify the event! [surprise]

The message you received is correct when required is set . . .



Calvin.gif
See Ya! . . . . . .
 
Sorry, if I don't understand. This is what I did.
I went to MyField properties, opened Event of the textboxes, scrolled down to KeyPress and typed in the code exactly as you gave it to me. There is nothing in Input Mask or Format.

 
frog40 . . .

That is not the event its the event line.
[ol][li]Put the cursor on the event line just above [blue]Key Press[/blue]. Tab into [blue]Key Press[/blue] and delete the code. Leave the cursor on the line.[/li]
[li]Now . . . click the [blue]three elipses[/blue] just to the right
Elipses.BMP
. If a [blue]Choose Builder Dialog[/blue] pops up select [blue]Code Builder[/blue] else you'll already be in the event in the [blue]Visual Basic Editor[/blue] (VBE) and the event will look like:
Code:
[blue]Private Sub [purple][b][i]TextboxName[/i][/b][/purple]_KeyPress(KeyAscii As Integer)

End Sub[/blue]
[/li]
[li]After you paste in the code it'll look like:
Code:
[blue]Private Sub [purple][b][i]TextboxName[/i][/b][/purple]_KeyPress(KeyAscii As Integer)
   If KeyAscii > 96 And KeyAscii < 123 Then
      KeyAscii = KeyAscii And 223
   End If
End Sub[/blue]
[/li]
[li]Hit the save button then hit [blue]Alt + Q[/blue] to return to form design view.[/li]
[li]Save, close the form and do your testing! . . .[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
AceMan1 you are the greatest. Greatest because you understand the "do not understand" of novices. Actually I was in Expression Builder instead of Code Buider. Now I realize how dumb that was, but thank you for your patience. I really appreciate your several responses until I got on the right tract.
FYI - your suggestion worked perfectly.
Thanx again, Frog40
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top