Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    330
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Capitals for Proper Names (Acc 97 sr2 on 95b)

    How can I force the first letter of inputted text into textboxes FirstName LastName to be saved and displayed as capitals?
    "Heading for the deep end"

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    I can suggest two options.
    One is an input mask, something like >L<&&&&&&&
    but you need to check the codes and think about what length and type of data you will accept.
    The other option is an afterupdate event
    Me!Firstname = strconv(Me![Firstname],3)
    strconv is the string convert function which will do a range of conversions - the parameter 3 tells it to convert to proper case.
    Regards
    John



  3. #3
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    Using the StrConv function is an excellent suggestion for this, but I would recommend using the form Before Update event, not the After Update event. You want to convert case BEFORE record is saved, not after. Testing this with After Update event resulted in all kinds of strange error messages.

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    That's interesting.
    I have done this in the afterupdate event for ages without problems, although I must confess I don't actually use strconv.
    I have a custom function I found some ago and use instead.
    Function CapitalizeFirst(x)
    ' Make first letter in field uppercase; leave other letters as typed.
    Dim Temp
    Temp = Trim(x)
    CapitalizeFirst = UCase(Left(Temp, 1)) & Mid(Temp, 2)

    End Function
    Regards
    John



  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    I just tested your suggestion, and whenever I put strconv in the beforeupdate event I got this error message, but no problems in the afterupdate.
    Attached Images Attached Images
    Regards
    John



  6. #6
    Star Lounger
    Join Date
    Feb 2003
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    John,

    I was searching through posts on how to capitalize just the first letter of a name and I came across your post. Can you give me a bit more info on the afterupdate event. Would this be a set value macro? If it is, how would the below info fit in the Item and Expression fields? Does Me! refer to the form the Firstname field resides?

    Thanks for your help.

    Scott

  7. #7
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    Hi Scott,

    Since John is presumably resting on his pillow, I'll take a first shot at answering your questions. The AfterUpdate event in this case is on the form control where the name is being entered, and the code involved is VBA, not a macro. To make that kind of code work, open the properties dialog box for the form, click in the control where the name is being entered, then select the AfterUpdate property, click on the builder (...) on the right side of the property, and tell it you want to create VBA code. That will open the VBA editor and you can enter the code from the prior post. Finally, Me! refers to the current form as you surmised. Post back if any of this doesn't make sense.
    Wendell

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    Wendell already explained what to do; here are some more details.

    If you want to convert a single field to proper case, use the AfterUpdate event of the control bound to the field. If you want to convert a series of fields to proper case, you can either use the AfterUpdate event for each of the controls bound to these fields, or use the BeforeUpdate event of the form. The difference is that the AfterUpdate event of a control will modify the text immediately when the user leaves the control by clicking somewhere else or by pressing Tab or Enter; the BeforeUpdate event of the form occurs when the user moves to another record or closes the form, so in general, the user won

  9. #9
    Star Lounger
    Join Date
    Feb 2003
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Capitals for Proper Names (Acc 97 sr2 on 95b)

    Hans and Wendell--

    Thanks so much. It worked like a champ!

    Scott

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •