Results 1 to 6 of 6
  1. #1
    Czoug is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    3

    VBA function (separating name from first name)

    Hi
    I have one column of first names combined with names(surenames) like:
    (not real names
    David Fare
    Felix Genth
    A.F. Berth
    Bern Nelroy
    V.N. Halu
    etc.
    I would like to sort this column to get surenames from A-Z, I was searching about a VBA function which would take from right side signs starting from first sign and ending by first space, but I can't find such one.
    Thanks for help

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    How about doing some manipulation in a query? Take a look at this video to get you started in the right direction.

    http://www.datapigtechnologies.com/f...anipulate.html

    Once you have looked at this, then you can apply the concept to creating new fields with first and last names that can be sorted any way you wish. Quick and easy and does not require VBA.

    Alan

  3. #3
    Czoug is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    3
    Didn't help. My last names are not constant(number of signs), his were. I need a function that take back not "x" letters, but in ranges as I sad.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Why don't you post your data base with some sample data in it so that we can play with it. I believe that using the Len function and the Mid function you can accomplish data manipulation of your information. This is something I have done in the past.

    Here is a solution that should work for you. In the example, change the underscore "_" to a space " " in your case.

    http://www.techonthenet.com/access/questions/parse.php

    Alan
    Last edited by alansidman; 02-17-2011 at 07:11 AM. Reason: Techonthenet solution posted.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,737
    You may be able to adapt this query. But it will not handle surnames like
    J.P. St. Pierre
    Claude Van Dam
    David del Rio
    Code:
    SELECT PersonNames.pName
    , Mid([pName],(InStrRev(Trim([PersonNames]![pName])," ")+1)) AS pSurname
    FROM PersonNames;
    where pName is the full text field to be parsed
    PersonNames is the name of the Table

  6. #6
    Czoug is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    3
    I have it. Very simple:
    split([pole],' ')(0) - first element
    split([pole],' ')(1) - second element

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

Similar Threads

  1. if function
    By lolo in forum Queries
    Replies: 1
    Last Post: 08-01-2010, 11:38 PM
  2. Separating Tables from Forms, etc
    By rtcary in forum Access
    Replies: 6
    Last Post: 07-16-2010, 01:39 PM
  3. Function Help
    By th3spankst3r in forum Programming
    Replies: 12
    Last Post: 03-22-2010, 12:41 PM
  4. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  5. Separating Street Number from Street
    By NGallone in forum Queries
    Replies: 0
    Last Post: 10-29-2008, 08:51 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