Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Help with Module

Discussion in 'Information Technology' started by brian b, Jul 28, 2006.

Tags:
  1. brian b

    brian b
    Expand Collapse
    Guest

    I am trying to import data from a text type file into a table. Problem is,
    the data involves names, some with middle initials, some without.

    I need the data to be without initials....so, I have the following line to
    add the data:

    tblEBIZHours![TECHNAME] = Left(tblEBIZTemp![Emp Nm], InStr(1,
    tblEBIZTemp![Emp Nm], ",") - 1) & ", " & Trim(Mid(tblEBIZTemp![Emp Nm],
    InStr(1, tblEBIZTemp![Emp Nm], " ") + 1, InStr(InStr(1, tblEBIZTemp![Emp Nm],
    " ") + 1, tblEBIZTemp![Emp Nm], " ") - InStr(1, tblEBIZTemp![Emp Nm], " ")))

    Which works fine if there is a middle initial, however, I error out if the
    code doesn't find anything with a middle initial. I tried an If...Then
    using IsNull, that didn't work either.

    Any suggestions?

    I'm using Access 2003
     
  2. Loading...


  3. Ken Snell \(MVP\)

    Ken Snell \(MVP\)
    Expand Collapse
    Guest

    Show us some sample data with and without the initials and identify the
    pieces of the data that you want to keep.

    --

    Ken Snell
    <MS ACCESS MVP>

    "brian b" <brianb@discussions.microsoft.com> wrote in message
    news:9347A5A1-0FC6-4FA5-B0E6-B2165F5E7D76@microsoft.com...
    >I am trying to import data from a text type file into a table. Problem is,
    > the data involves names, some with middle initials, some without.
    >
    > I need the data to be without initials....so, I have the following line to
    > add the data:
    >
    > tblEBIZHours![TECHNAME] = Left(tblEBIZTemp![Emp Nm], InStr(1,
    > tblEBIZTemp![Emp Nm], ",") - 1) & ", " & Trim(Mid(tblEBIZTemp![Emp Nm],
    > InStr(1, tblEBIZTemp![Emp Nm], " ") + 1, InStr(InStr(1, tblEBIZTemp![Emp
    > Nm],
    > " ") + 1, tblEBIZTemp![Emp Nm], " ") - InStr(1, tblEBIZTemp![Emp Nm], "
    > ")))
    >
    > Which works fine if there is a middle initial, however, I error out if the
    > code doesn't find anything with a middle initial. I tried an If...Then
    > using IsNull, that didn't work either.
    >
    > Any suggestions?
    >
    > I'm using Access 2003
     
  4. brian b

    brian b
    Expand Collapse
    Guest

    The text file carries in "SMITH, JOHN P" or "DOE, JANE"

    I need only the last name and first name.

    "Ken Snell (MVP)" wrote:

    > Show us some sample data with and without the initials and identify the
    > pieces of the data that you want to keep.
    >
    > --
    >
    > Ken Snell
    > <MS ACCESS MVP>
    >
    > "brian b" <brianb@discussions.microsoft.com> wrote in message
    > news:9347A5A1-0FC6-4FA5-B0E6-B2165F5E7D76@microsoft.com...
    > >I am trying to import data from a text type file into a table. Problem is,
    > > the data involves names, some with middle initials, some without.
    > >
    > > I need the data to be without initials....so, I have the following line to
    > > add the data:
    > >
    > > tblEBIZHours![TECHNAME] = Left(tblEBIZTemp![Emp Nm], InStr(1,
    > > tblEBIZTemp![Emp Nm], ",") - 1) & ", " & Trim(Mid(tblEBIZTemp![Emp Nm],
    > > InStr(1, tblEBIZTemp![Emp Nm], " ") + 1, InStr(InStr(1, tblEBIZTemp![Emp
    > > Nm],
    > > " ") + 1, tblEBIZTemp![Emp Nm], " ") - InStr(1, tblEBIZTemp![Emp Nm], "
    > > ")))
    > >
    > > Which works fine if there is a middle initial, however, I error out if the
    > > code doesn't find anything with a middle initial. I tried an If...Then
    > > using IsNull, that didn't work either.
    > >
    > > Any suggestions?
    > >
    > > I'm using Access 2003

    >
    >
    >
     
  5. Ken Snell \(MVP\)

    Ken Snell \(MVP\)
    Expand Collapse
    Guest

    Try this:

    tblEBIZHours![TECHNAME] = IIf(InStr(InStr(tblEBIZTemp![Emp Nm], ", ") + 2,
    tblEBIZTemp![Emp Nm], " ") <> 0, Left(tblEBIZTemp![Emp Nm],
    InStr(InStr(tblEBIZTemp![Emp Nm], ", ") + 2, tblEBIZTemp![Emp Nm], " ") -
    1), tblEBIZTemp![Emp Nm])
    --

    Ken Snell
    <MS ACCESS MVP>



    "brian b" <brianb@discussions.microsoft.com> wrote in message
    news:E2487C67-B58C-4D34-99EC-E1F982C8E8A8@microsoft.com...
    > The text file carries in "SMITH, JOHN P" or "DOE, JANE"
    >
    > I need only the last name and first name.
    >
    > "Ken Snell (MVP)" wrote:
    >
    >> Show us some sample data with and without the initials and identify the
    >> pieces of the data that you want to keep.
    >>
    >> --
    >>
    >> Ken Snell
    >> <MS ACCESS MVP>
    >>
    >> "brian b" <brianb@discussions.microsoft.com> wrote in message
    >> news:9347A5A1-0FC6-4FA5-B0E6-B2165F5E7D76@microsoft.com...
    >> >I am trying to import data from a text type file into a table. Problem
    >> >is,
    >> > the data involves names, some with middle initials, some without.
    >> >
    >> > I need the data to be without initials....so, I have the following line
    >> > to
    >> > add the data:
    >> >
    >> > tblEBIZHours![TECHNAME] = Left(tblEBIZTemp![Emp Nm], InStr(1,
    >> > tblEBIZTemp![Emp Nm], ",") - 1) & ", " & Trim(Mid(tblEBIZTemp![Emp Nm],
    >> > InStr(1, tblEBIZTemp![Emp Nm], " ") + 1, InStr(InStr(1,
    >> > tblEBIZTemp![Emp
    >> > Nm],
    >> > " ") + 1, tblEBIZTemp![Emp Nm], " ") - InStr(1, tblEBIZTemp![Emp Nm], "
    >> > ")))
    >> >
    >> > Which works fine if there is a middle initial, however, I error out if
    >> > the
    >> > code doesn't find anything with a middle initial. I tried an If...Then
    >> > using IsNull, that didn't work either.
    >> >
    >> > Any suggestions?
    >> >
    >> > I'm using Access 2003

    >>
    >>
    >>
     

Share This Page