Results 1 to 9 of 9
  1. #1
    Join Date
    May 2014
    Posts
    14

    Unanswered: Proper Case Format Using Code

    I have created this After Update code to generate proper text formatting so when someone enters a name it capitalizes the first letter in each name. (i.e. jane smith it would be viewed as Jane Smith. Code does perfect for that; however when I add parentheses to show maiden name it throws it off. The current after update event code below leaves it as Jane (jones) Smith. I would like it to read Jane (Jones) Smith
    This Is My Current Code:
    Private Sub MothersNameMaiden_AfterUpdate()
    MothersNameMaiden = StrConv(MothersNameMaiden, (vbProperCase)
    End Sub

    Thanks All For your help and consideration.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    What do you mean by 'isnt working'
    What error message, if any do you get?
    Does the code run, does it do anything?
    ...have you put a breakpoint on the function and stepped through it?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    As pointed out elsewhere, you have an extra parentheses in your formula:

    StrConv(MothersNameMaiden, (vbProperCase)

    If you're saying the maiden name is inside parentheses in the field, I don't think the formula will touch it:

    ?StrConv("jane (jones) smith", vbProperCase)
    Jane (jones) Smith

    ?StrConv("jane jones smith", vbProperCase)
    Jane Jones Smith
    Paul

  4. #4
    Join Date
    May 2014
    Posts
    14
    The actual code I am using is was a typo when I added it here.

    MothersNameMaiden = StrConv(MothersNameMaiden, vbProperCase)

    However, when I add information such as Jane (Jones) Smith it changes it to Jane (jones) Smith. When I enter it as jane (jones) Smith it changes it to Jane (jones) Smith somehow when it sees it in the parentheses it reverts everything inside the parentheses it to lower case.

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    First Google result:

    StrConv first character inside ()
    Paul

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Well I suppose you could replace the opening bracket with some other symbol, do the proper case conversion then replace the other symbol with the opening bracket...

    ....messy but it should work
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    The problem, of course, is that Access is interpreting the opening parens as the first 'letter' and not the actual first letter of the maiden name. This does the job for me:
    Code:
    Private Sub MothersNameMaiden_AfterUpdate()
    
      Me.MothersNameMaiden = Replace(Me.MothersNameMaiden, "(", "( ")
    
      Me.MothersNameMaiden = StrConv(Me.MothersNameMaiden, vbProperCase)
    
      Me.MothersNameMaiden = Replace(Me.MothersNameMaiden, "( ", "(")
    
    End Sub

    Linq ;0)>
    Last edited by Missinglinq; 08-13-14 at 13:50.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    Join Date
    May 2014
    Posts
    14

    Using a () with Proper Case

    Private Sub MothersNameMaiden_AfterUpdate()

    Me.MothersNameMaiden = Replace(Me.MothersNameMaiden, "(", "( ")

    Me.MothersNameMaiden = StrConv(Me.MothersNameMaiden, vbProperCase)

    Me.MothersNameMaiden = Replace(Me.MothersNameMaiden, "( ", "(")

    End Sub


    Works perfect!! Thank you I see now what you mean about code seeing ( as the first letter. Which than forced it to lower case.

  9. #9
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad it works for you!

    Good luck with your project!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Tags for this Thread

Posting Permissions

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