Andrzej Opiela
Andrzej Opiela

Reputation: 7

Input mask in MS Access, uppercase and lowercase letters

this "<" symbol, change input text to lowercase, this ">" change input text to uppercase

My question is. How can i change input text to normal(uppercase or lowercase)
after using one of the symbols <,>.

For example I'd like to create input mask like that

abcdef(must be lowercase)AbCdefG(Can be uppercase or lowercase)

First 6th leeter must be lowercase, and the rest can be uppercase or lowercase

Upvotes: 0

Views: 4618

Answers (1)

Renaud Bompuis
Renaud Bompuis

Reputation: 16786

Input masks in Access are a bit limited. You'll have to get down to VBA to get what you want.

For instance:

Private Sub txtbox_KeyPress(KeyAscii As Integer)
    ' Convert the typed key to upper case
    KeyAscii = Asc(UCase$(Chr$(KeyAscii)))

    ' Only Allow user to type letters A-E and 1-6
    If KeyAscii >= 32 Then
        If InStr(1, "ABCDE123456", Chr$(KeyAscii), 1) = 0 Then
            KeyAscii = 0
        End If
        ' Stop the input after the user typed 5 characters
        If Len(txtbox.Text) = 5 Then KeyAscii = 0
    End If
End Sub

This will only allow the user to type up to 5 characters in the text box.
Only characters A to E and numbers 1 to 6 are allowed, and they are typed in upper-case.

You will need to adapt for your specific case and can use the KeyDown, KeyPress and Change events to detect and shape data entry.

Upvotes: 3

Related Questions