A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Pulling specific data from table field



 
 
Thread Tools Display Modes
  #1  
Old June 3rd, 2010, 08:55 PM posted to microsoft.public.access.queries
jet04 via AccessMonster.com
external usenet poster
 
Posts: 2
Default Pulling specific data from table field

I am having a problem figuring the right way to pull specific data from
within the text of the table's field and separating it into a unique field
alone.

Anyway, my problem is that I need to copy a user's first name out of a field
that contains system user information, and then pull the last name out
separately as well, both uniquely. I don't mind having separate queries to do
this (although one would be preferred of course).

Table: tbl1
Field: userinfo

Example of field data: ABD 000000 111, Doe John, R, W, T22222222, T333333

The ABC and 111 are constants within the field, and the 000000 is a serial
number with a standard length of 6.

I currently have a sql query that pulls the serial number:
UPDATE tbl1
SET tbl1.[Serrial Number] = Right(Left([tbl1].[userinfo],10),6);

Obviously this won't work with for a last name or first name because the
number of letters within a name can change... so I'm stumped as how to
correctly format a query to copy the last name and first name into a separate
field.

Any thoughts?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201006/1

  #2  
Old June 3rd, 2010, 11:10 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Pulling specific data from table field

Try these --
LName: Mid([tbl1].[userinfo], 17, Instr(20,[tbl1].[userinfo], " ")-16)

FName: Mid([tbl1].[userinfo],InStr(20,[tbl1].[userinfo],"
")+1,InStr(23,[tbl1].[userinfo],", ")-InStr(20,[tbl1].[userinfo]," ")-1)

Then build on the first name one for initals.

--
Build a little, test a little.


"jet04 via AccessMonster.com" wrote:

I am having a problem figuring the right way to pull specific data from
within the text of the table's field and separating it into a unique field
alone.

Anyway, my problem is that I need to copy a user's first name out of a field
that contains system user information, and then pull the last name out
separately as well, both uniquely. I don't mind having separate queries to do
this (although one would be preferred of course).

Table: tbl1
Field: userinfo

Example of field data: ABD 000000 111, Doe John, R, W, T22222222, T333333

The ABC and 111 are constants within the field, and the 000000 is a serial
number with a standard length of 6.

I currently have a sql query that pulls the serial number:
UPDATE tbl1
SET tbl1.[Serrial Number] = Right(Left([tbl1].[userinfo],10),6);

Obviously this won't work with for a last name or first name because the
number of letters within a name can change... so I'm stumped as how to
correctly format a query to copy the last name and first name into a separate
field.

Any thoughts?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201006/1

.

  #3  
Old June 4th, 2010, 01:29 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Pulling specific data from table field

On Thu, 03 Jun 2010 19:55:28 GMT, "jet04 via AccessMonster.com" u60414@uwe
wrote:

I am having a problem figuring the right way to pull specific data from
within the text of the table's field and separating it into a unique field
alone.

Anyway, my problem is that I need to copy a user's first name out of a field
that contains system user information, and then pull the last name out
separately as well, both uniquely. I don't mind having separate queries to do
this (although one would be preferred of course).

Table: tbl1
Field: userinfo

Example of field data: ABD 000000 111, Doe John, R, W, T22222222, T333333

The ABC and 111 are constants within the field, and the 000000 is a serial
number with a standard length of 6.

I currently have a sql query that pulls the serial number:
UPDATE tbl1
SET tbl1.[Serrial Number] = Right(Left([tbl1].[userinfo],10),6);

Obviously this won't work with for a last name or first name because the
number of letters within a name can change... so I'm stumped as how to
correctly format a query to copy the last name and first name into a separate
field.

Any thoughts?


Karl's code will let you handle the simple cases, but there are names that
don't fit the pattern. What about a name like "Billy Joe McAlister" - first
name Billy Joe (just ask him)? And how about "Hans ten Broek" - first name
Hans, last name ten Broek?

Names are messy, and may well require a USB (Using Someone's Brain) interface.
--

John W. Vinson [MVP]
  #4  
Old June 4th, 2010, 03:43 PM posted to microsoft.public.access.queries
jet04 via AccessMonster.com
external usenet poster
 
Posts: 2
Default Pulling specific data from table field

Karl,

Thanks for you help on this one, it really was just frustrating me! The
Last Name search completely worked, but I am having issues pulling the First
Name data.

When running the First Name query, an error is returned saying Access
was unable to update a number of fields due to a type conversion failure. It
states this is due to key violations, lock violations, and validation rule
violations.

I'm wondering if this is because of what John menioned in this string,
which is something I have found to be true of my table. There are a few
instances of a third name being within the userinfo field. I should have
perused my file to recognize that issue, but in my frustration it seems I
overlooked the third name.

Example: ABC 000000 111, Doe John Paul, R, W, T222222

I'm not sure there is an answer as how to work around this problem, but
thought I'd at least give some feedback as to how the help you'd given me
worked out. Thanks again for the suggestion and I'm going to keep working on
this and see if there is a solution to my problem.



KARL DEWEY wrote:
Try these --
LName: Mid([tbl1].[userinfo], 17, Instr(20,[tbl1].[userinfo], " ")-16)

FName: Mid([tbl1].[userinfo],InStr(20,[tbl1].[userinfo],"
")+1,InStr(23,[tbl1].[userinfo],", ")-InStr(20,[tbl1].[userinfo]," ")-1)

Then build on the first name one for initals.

I am having a problem figuring the right way to pull specific data from
within the text of the table's field and separating it into a unique field

[quoted text clipped - 23 lines]

Any thoughts?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201006/1

  #5  
Old June 7th, 2010, 04:24 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Pulling specific data from table field

due to a type conversion failure. It states this is due to key violations,
lock violations, and validation rule violations.
First you have to figure out which of the reasons give you the error. Review
what worked and then look at what did not.

--
Build a little, test a little.


"jet04 via AccessMonster.com" wrote:

Karl,

Thanks for you help on this one, it really was just frustrating me! The
Last Name search completely worked, but I am having issues pulling the First
Name data.

When running the First Name query, an error is returned saying Access
was unable to update a number of fields due to a type conversion failure. It
states this is due to key violations, lock violations, and validation rule
violations.

I'm wondering if this is because of what John menioned in this string,
which is something I have found to be true of my table. There are a few
instances of a third name being within the userinfo field. I should have
perused my file to recognize that issue, but in my frustration it seems I
overlooked the third name.

Example: ABC 000000 111, Doe John Paul, R, W, T222222

I'm not sure there is an answer as how to work around this problem, but
thought I'd at least give some feedback as to how the help you'd given me
worked out. Thanks again for the suggestion and I'm going to keep working on
this and see if there is a solution to my problem.



KARL DEWEY wrote:
Try these --
LName: Mid([tbl1].[userinfo], 17, Instr(20,[tbl1].[userinfo], " ")-16)

FName: Mid([tbl1].[userinfo],InStr(20,[tbl1].[userinfo],"
")+1,InStr(23,[tbl1].[userinfo],", ")-InStr(20,[tbl1].[userinfo]," ")-1)

Then build on the first name one for initals.

I am having a problem figuring the right way to pull specific data from
within the text of the table's field and separating it into a unique field

[quoted text clipped - 23 lines]

Any thoughts?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201006/1

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.