Help with Module

  • Thread starter Thread starter Guest
  • Start date Start date
G

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
 
Show us some sample data with and without the initials and identify the
pieces of the data that you want to keep.
 
The text file carries in "SMITH, JOHN P" or "DOE, JANE"

I need only the last name and first name.

Ken Snell (MVP) said:
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 said:
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
 
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 said:
The text file carries in "SMITH, JOHN P" or "DOE, JANE"

I need only the last name and first name.

Ken Snell (MVP) said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top