Re: Help With Multiple Tables, Fields and 'query' -
- From: Doc <pc-dc-doc@xxxxxxxxxxx>
- Date: Tue, 12 Sep 2006 13:53:18 -0700
OUCH - did the "update query" and under FIRST NAME, it WROTE "NAME" to
all of them -
Believe my error to be upon 'parameter' query as I started to run the
UPDATE, I placed "name" (thinking I was using the 'field' value to be
split at the ~ in the 'name' field - but I obviously don't know what I
did), and 'name' came out in the 'first name' new field (nothing in last
name)...
To recap
Original field is "name" - data in that field "first name ~ last name"
Desire to dump the ~ *and* to separate the first and last names INTO
new fields called "First name" and "Last Name" -
There are some "organizations" that do NOT have a ~ anywhere, I do
want to bring them out and place them into a NEW field called
"organizations" - and key them all with the USER ID field which has
always existed.
I can make changes to the DATABASE upon opening it.
I can add or subtract fields.
I must've misread the instructions. Ideas? Thank you very much John.
John Spencer typed this:
First, in the existing table(s), can you manually change the data in.
the table view. If you can't do this then we have to explore other
methods.
Do the existing tables have a field (Column) for FirstName, LastName,
and Organization?
If you can manually update the table contents and the fields exist in
the existing table, you can use an update query to update each
record.
Create a query that shows you the fields you want to update
(populate). FirstName, LastName, Organization Add ClientID and the
Name field (FieldName)
Now, Select Query: Update from the menu
Under FirstName in the UPDATE TO cell enter the formula TRIM(Left([tblName].[FieldName],Instr(1,[tblName].[FieldName],"~")))
UnderLastName enter the formula TRIM(MID([tblName].[FieldName],1+Instr(1,[tblName].[FieldName],"~")))
Under the FieldName in the criteria enter Like "*~*"
Select Query: Run from the menu
That should split out the names.
If you don't want to replace existing data add criteria Is Null under
FirstName and Is Null under LastName that will only update records
where both FirstName and LastName is currently blank.
Organization can be done separately. Field: ORganization Update To:
[TblName].[FieldName] Criteria: Is Null
Field: FieldName Update To: <<Leave blank>> Criteria: Not Like "*~*"
"Doc" <pc-dc-doc@xxxxxxxxxxx> wrote in message news:4505ba9c$0$24213$9a6e19ea@xxxxxxxxxxxxxxxxxxxxxxxJohn Spencer typed this:You're not all that clear in what you want to do. Do you need to
edit the data? Are you importing the data into Access tables and
want to set the fields up when you do? Is ClientID in a separate
field from the Name information?
You could use an append query to shove the ClientID and names
into fields in a predefined table.
INSERT INTO YourTempTable (ClientID, LastName, FirstName, Organization) SELECT ClientID , IIF(TblName.FieldName Like "*~*",TRIM(Left(tblName.FieldName,Instr(1,tblName.FieldName,"~")))
, IIF(TblName.FieldName Like "*~*",TRIM(MID(tblName.FieldName,1+Instr(1,tblName.FieldName,"~")))
, IIF(TblName.FieldName NOT Like "*~*",TblName.FieldName) FROM
tblName WHERE TblName.FieldName is not null
Now you should be able to set up a join between the client id in
YourTempTable and the SourceTable (tblName).
If all you need to do is view the information, then you could use
the above calculations to show LastName, FirstName, and
Organizaion
"Doc" <pc-dc-doc@xxxxxxxxxxx> wrote in message news:45058f59$0$24187$9a6e19ea@xxxxxxxxxxxxxxxxxxxxxxxHello, I use MS Access 2003 on Win XP (SP2). I am opening 'exported' (DTS) data from a Solomon DB that has about 1400
tables and from 10 to 50 fields per table (Yuk!). Several major
tables have a 'field name' of NAME and within those columns
(~140,000 rows) I have a 'last name' ~ 'first name' - importantly I also have a 'client ID' field that must stay 'related' to the NAME. I want to take my single column (Field)
and bring out the names, rid myself of the ~ between the last
and first name, have it create "two" fields (Last name, First
name) and YET retain my connection with the "client ID" field
for 'importation' back INTO the DATABASE (which uses the CLIENT
ID as the Key). One "last" complication. In the "name" field
there are SOME single named entries WITHOUT a ~ because they
are 'businesses' - I would love to pull those out and place
them in a field called "organization" and ALSO still retain the
"key" relationship. Any helps is greatly appreciated. Thanks
very much. Doc in "Los Angeles" mailto: pc-dc-doc@xxxxxxxxxxx
yes... "client ID" field is separate from the "name" field. No. I
just want to separate the current "name" field into two fields (first name, last name) and remove the ~ that resides in between
the names in the current "name" field. I do NEED to bring the
'newly' created FIELDS (first name, last name) back into the
DATABASE along with the separated "Organization" field... all to be
linked with the "Client ID" field (key).
I won't be taking anything out or adding anything to the table
regarding population of fields.
Not sure here (INSERT INTO YourTempTable) what you mean? Are you
saying to 'create' a new temporary table or will the commands you
provided just create it in memory?
Thanks. I don't know much about access but I was tasked with doing
this. I do networking and all aspects of IT but not DB. Thanks
again.
Doc in "Los Angeles" mailto: pc-dc-doc@xxxxxxxxxxx
- Follow-Ups:
- Re: Help With Multiple Tables, Fields and 'query' -
- From: John Spencer
- Re: Help With Multiple Tables, Fields and 'query' -
- References:
- Help With Multiple Tables, Fields and 'query' -
- From: Doc
- Re: Help With Multiple Tables, Fields and 'query' -
- From: John Spencer
- Re: Help With Multiple Tables, Fields and 'query' -
- From: Doc
- Re: Help With Multiple Tables, Fields and 'query' -
- From: John Spencer
- Help With Multiple Tables, Fields and 'query' -
- Prev by Date: Re: Out of memory
- Next by Date: Re: Out of memory
- Previous by thread: Re: Help With Multiple Tables, Fields and 'query' -
- Next by thread: Re: Help With Multiple Tables, Fields and 'query' -
- Index(es):
Relevant Pages
|