Force the first letter to uppercase in Access.

Erwan51 -  
seyou Posted messages 27 Status Member -
Hello,

I would like to force only the first letter of a text field in Access 2000 to be uppercase. It is a string field. => example: julien becomes Julien

Thank you in advance

Erwan51

2 answers

  1. seyou Posted messages 27 Status Member 1
     
    To force the first character of a text field to be uppercase, and the
    other characters to be lowercase, you can use the Input Mask property
    of the text type field:

    >?<?????????

    The number of question marks following the < symbol must
    ideally match the length of the field.
    1
  2. Erwan51
     
    To convert everything to uppercase, you need to put > in the format section of a field, so I suppose it must be the same principle to capitalize just one letter...

    Erwan51
    0
    1. Antoine
       
      Hello,

      To force the first letter to be uppercase in Access, you can use the following small piece of code that allows you to do it directly while entering in the control:
      On your Text field, create a "KeyPress" event and paste the following code:

      If KeyAscii > 64 Then
      'check if we are at the first character
      If [Control Name].SelStart = 0 Then
      ' convert to uppercase
      KeyAscii = Asc(UCase(Chr(KeyAscii)))
      Else
      ' convert to lowercase
      KeyAscii = Asc(LCase(Chr(KeyAscii)))
      End If
      End If

      There you go... happy typing!!!

      Antoine
      Analyst Developer.NET
      0