Results 1 to 10 of 10
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Find and replace help: Smith/jones to Smith/Jones

    Hey guys,

    Little help if you don't mind. Making a mail merge list and the last names for unmarried couple have been pulled out of the database as "Smith/jones." This looks terrible on a letter (the lowercase of the second name). I have tried the following, and it works great in the immediate window, but when I put it into the query, it converts everything to uppercase. Any ideas?

    Code:
    Replace("Smith/jones","/" & Mid("Smith/jones", InStr("Smith/jones","/")+1,1),StrConv(Mid("Smith/jones",InStr("Smith/jones","/"),2),1)) 




    When I put in the actually field name ([SHIP_TO_LNAME]) in place of "Smith/jones," it just puts everything to upper case.

  2. #2
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Actually, it puts all of the names with a "/" to upper case, if a name doesn't have a "/," ie "Jones" it errors out.

    Now I'm really stumped.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I have the following in a general module to adjust the first letter in a field to capital. I just CALL "NoCaps". The part you are looking for is vbProperCase within StrConv

    Public Function NoCaps(strText As String) As String
    NoCaps = StrConv(strText, vbProperCase)
    End Function

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    But "Smith/jones" is 1 word. That doesn't capitalize the "j," tried that.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    I am not familiar with your tables. For me, I usually have first and last names in separate columns SOMEWHERE. So if I import data, I put it into tables in a way I can index it, assign Keys, sort, etc.

    I suppose you are going to need to use the forward slash to get first and last separated. Use the character as a delimiter so to speak. You could do the whole thing logically or you could place the separated data into a table for safe keeping.

  6. #6
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Like I said, these are just the last names. First names are already separated. If Wendy Smith and Bob Jones bought something, it got keyed as FNAME=WENDY/BOB, LNAME=SMITH/JONES. The first names have been converted to Wendy & Bob, but the last names are to stay "slashed" but I want the 2nd last name to be capitalized.

    Obviously I could use 3 queries to break them apart, capitalize, then put them back together. I am just trying to avoid that.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by snipe View Post
    Like I said, these are just the last names. First names are already separated. If Wendy Smith and Bob Jones bought something, it got keyed as FNAME=WENDY/BOB, LNAME=SMITH/JONES. The first names have been converted to Wendy & Bob, but the last names are to stay "slashed" but I want the 2nd last name to be capitalized.

    Obviously I could use 3 queries to break them apart, capitalize, then put them back together. I am just trying to avoid that.
    I see. This one is obviously above my pay grade.

  8. #8
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Well I appreciate you taking a look at it

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Might require a custom VBA function to handle because of the inconsistency in presence of /.

    Call function from the update query just like calling intrinsic function. Here is a simple example, assumes only one /.

    Put function in a general code module.

    Function FixCap(strName As String) As String
    Dim aryNames As Variant
    FixCap = strName
    If InStr(strName, "/") > 0 Then
    aryNames = Split(strName, "/")
    FixCap = aryNames(0) & "/" & StrConv(aryNames(1), vbProperCase)
    End If
    End Function

    Probably insignificant but this means last names that would not customarily be capitalized will be. Vincent Willem van Gogh is one. Seems the van in Dutch names is often not capitalized.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Perfect, June7. I had to add a StrConv to aryNames(0) as all of the data is originally in all caps. Works perfect now. Thanks a bunch!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Find and Replace
    By dweekley in forum Queries
    Replies: 3
    Last Post: 04-12-2013, 07:16 AM
  2. Replies: 5
    Last Post: 02-12-2013, 09:12 AM
  3. find and replace
    By rohini in forum Access
    Replies: 7
    Last Post: 05-17-2012, 05:23 AM
  4. Find and Replace
    By Bedsingar in forum Access
    Replies: 1
    Last Post: 08-14-2011, 01:10 PM
  5. Find and Replace Query
    By randolphoralph in forum Queries
    Replies: 4
    Last Post: 03-17-2010, 07:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums