Results 1 to 8 of 8
  1. #1
    JJPetersen1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jan 2020
    Posts
    18

    Remove characters from a field


    Looking for a way to remove all characters, right of a space, in a field

  2. #2
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Quote Originally Posted by JJPetersen1 View Post
    Looking for a way to remove all characters, right of a space, in a field
    Got an example?

    RTRIM() will remove trailing non-printing characters.

    Otherwise, you'd need to use INSTR() to get the position of the space, and then maybe LEFT() to get everything up to that. (so maybe subtract 1 from the length.

  3. #3
    JJPetersen1 is offline Novice
    Windows 8 Access 2016
    Join Date
    Jan 2020
    Posts
    18
    AARON B A
    SHELBY
    SALLY MARY

    When I get my listing, I get a listing of names that are inconsistent, some are Last Name, First Name, some are Last Name, Two first names, etc. I have a query to extract the last name ... LName: Mid([FullName],1,InStr([FullName],',')-1). I tried using LName: Mid([FullName],1,InStr([FullName],',')-1) to extract the first name. It's works, unless the person doesn't have a middle name or middle initial (function error). So I tried ... FName1: Mid([FullName],InStrRev([FullName],",")+2). This extracts the examples above. I tried and tried to no avail. Any help would be appreciated

  4. #4
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Oh right. Mailing lists. These are a horror show to fix sometimes, because it's hard to tell programmatically which is a first name and which is a last name. (Like Aaron Neville... if you hadn't heard of him, which is first name, which is last name?) You could, I guess, have a list of common first names, but even then it would not be 100% accurate.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I would save everything as it is presented to you.
    You cannot determine whether Sally Mary is first and last or last and first.
    Old adage, garbage in garbage out.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    i not really understand ur function use because u talk about space and u test comma, change comma into space lname should be ok

  7. #7
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Quote Originally Posted by Welshgasman View Post
    I would save everything as it is presented to you.
    You cannot determine whether Sally Mary is first and last or last and first.
    Old adage, garbage in garbage out.
    That was the point of the "Aaron Neville" example. Unless you have outside knowledge, there's no way to tell which is the first name and which is the last name.

    There have been discussions about this for YEARS. I'm pretty sure I was discussing this or something very similar with Larry Linson like 10 years ago.

  8. #8
    TheSolver is offline Novice
    Windows 11 Office 365
    Join Date
    Aug 2024
    Posts
    2
    Hello Sir.

    If database design is donned corretly there could be 3 fields...First name, Middle Name, Last Name.
    Maybe now reinput data in correct field struture.

    Take care.

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

Similar Threads

  1. Remove a string between 2 characters
    By PasJes in forum Queries
    Replies: 4
    Last Post: 11-15-2023, 05:13 PM
  2. How to remove last characters of a string?
    By MsAxes in forum Modules
    Replies: 3
    Last Post: 03-20-2023, 10:15 AM
  3. Replies: 12
    Last Post: 03-03-2013, 07:13 PM
  4. Replies: 5
    Last Post: 06-28-2012, 10:49 AM
  5. Replies: 5
    Last Post: 03-10-2011, 02:19 PM

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