Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    separate name (2002)

    What is the code to pull out the Last Name and the First Name from a field called LNFN (Smith; Mary) and put them is separate fields.

    I thought I knew how to do this but I can't get my code to work.

    Thanks.

    Paul

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: separate name (2002)

    Create a query based on the table.

    Create a calculated column:
    <code>
    LastName: Left([LNFN], InStr([LNFN], ";") - 1)
    </code>
    and another calculated column:
    <code>
    FirstName: Mid([LNFN], InStr([LNFN], ";") + 2)</code>

  3. #3
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: separate name (2002)

    I should have explained more about what I was doing. The code works for a query but that was not how I was trying to use it.

    I have a form with a combobox linked to a query that has three fields LNFN, LN, FN. The record source for the form is another table. I want to put LNFN, FN and LN in the source table. I can link the LNFN combo field to the source table but not directly link the LN and FN fields. I was trying to use the code you provided in textboxes on the form so that I could add the LN and FN values to the table.

    I can't quite make it work. I'm making the whole process too complicated. There has to be a better way.

    Paul

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: separate name (2002)

    You shouldn't store LNFN, LN and FN in a table. Either store LNFN, or store LN and FN. You can derive LN and FN from LNFN the way I showed, or you can derive LNFN from LN and FN by concatenation.

Posting Permissions

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