Results 1 to 3 of 3
  1. #1
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407

    basic string manipulation

    Hi all,
    A simple one here, i have several strings of employee names, they are first name and last name this is combined with an underscore inbetween them no spaces. eg trevor_smith.
    i need to extract both parts of the name only without the underscore, first name into a text box and last name into another text box.


    i am shure this is very simple but i don't have much exp in string manipulation and i am out of time with this db design.

    hope you can help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Left([fieldname], InStr([fieldname],"_")-1)

    Mid([fieldname], InStr([fieldname],"_")+1)

    http://www.databasedev.co.uk/access-...functions.html

    https://msdn.microsoft.com/en-us/library/dd789093.aspx
    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.

  3. #3
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    Quote Originally Posted by June7 View Post
    Left([fieldname], InStr([fieldname],"_")-1)

    Mid([fieldname], InStr([fieldname],"_")+1)

    http://www.databasedev.co.uk/access-...functions.html

    https://msdn.microsoft.com/en-us/library/dd789093.aspx
    thanks but in the mean time i did this, all to convert the sheet name into seperate first and last names and put the result in cells

    Current_Worksheet.Range("Q1").Value = Excel_Workbook.Worksheets(sheet_count).Name
    Current_Worksheet.Range("R1").Formula = "=Left(Q1, (Find(""_"", Q1) - 1))"
    Current_Worksheet.Range("S1").Formula = "=Len(Left(Q1,(Find(""_"", Q1))+1))"
    Current_Worksheet.Range("T1").Formula = "=MID(Q1,S1,100)"
    Current_Worksheet.Range("G1").Value = Current_Worksheet.Range("R1").Value
    Current_Worksheet.Range("M1").Value = Current_Worksheet.Range("T1").Value

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

Similar Threads

  1. String text manipulation
    By justphilip2003 in forum Access
    Replies: 2
    Last Post: 03-21-2013, 09:56 PM
  2. Replies: 3
    Last Post: 04-23-2012, 12:06 AM
  3. Form manipulation error
    By witooldas in forum Forms
    Replies: 6
    Last Post: 03-18-2011, 02:40 AM
  4. date manipulation
    By lpsd in forum Access
    Replies: 3
    Last Post: 12-23-2010, 12:06 PM
  5. Query manipulation using VBA
    By benattal in forum Programming
    Replies: 0
    Last Post: 12-31-2008, 09:12 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