Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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

    >>
    >>
    >>
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page