473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Query Issue while splitting a field.

Hi there,

I'm currently trying to fix up a database that has had many different
people work on it and therefore is confusing me no end.

Currently i am trying to update a field, [Person ID] in the table
[CAST] .

[Person ID] is a numeric field and is linked to the [Personnel Tbl]
(its the PK)
this needs to be updated according to another field [By Whom] in the
[CAST] table, which is a text field.

[By Whom] is in the format of Surname, First Name

so what i need to know is how do i write an update query that will
update [Person ID] to be a reference of the [Personnel Tbl] according
to the surname in the [By Whom] field.

I hope this makes sense and appreciate any help i can get, my head is
getting sore!

Cheers, Aaron

Dec 6 '06 #1
3 1598
On 5 Dec 2006 19:56:28 -0800, aa*****@aapt.net.au wrote:

Your explanation makes sense, but it also shows a VERY BAD database
design.
ByWhom should be replaced by a PersonID. This works towards the power
of relational databases. Work on that first. Other issues will start
falling into place.

-Tom.
>Hi there,

I'm currently trying to fix up a database that has had many different
people work on it and therefore is confusing me no end.

Currently i am trying to update a field, [Person ID] in the table
[CAST] .

[Person ID] is a numeric field and is linked to the [Personnel Tbl]
(its the PK)
this needs to be updated according to another field [By Whom] in the
[CAST] table, which is a text field.

[By Whom] is in the format of Surname, First Name

so what i need to know is how do i write an update query that will
update [Person ID] to be a reference of the [Personnel Tbl] according
to the surname in the [By Whom] field.

I hope this makes sense and appreciate any help i can get, my head is
getting sore!

Cheers, Aaron
Dec 6 '06 #2
Your explanation makes sense, but it also shows a VERY BAD database
design.
ByWhom should be replaced by a PersonID. This works towards the power
of relational databases. Work on that first. Other issues will start
falling into place.
Thanks for the reply Tom,
You're dead right, it is a wizard nightmare!

The main issue is that this database system is used on several
different sites
(all separate data) and the solution has to be automated. There is
heaps of
data as well. I have fixed it up so that all new data is written to
PersonID,
but need to get the old data from ByWhom to PersonID, which is hard
because one
is numerical and the other text.

I have tried changing PersonID to a text field and running a simple
update
query, this looks like it works but none of the reports work because
the
updated data is in text not a numerical reference to the PersonnelTbl.

I then tried a left split formula to separate the surname and insert
the PersonnelID according to the surname but this comes up with an
error message ( I can't remember what it is, will post in an hour or
so).

Any ideas would be great, i'm running in circles

Cheers Aaron.

Dec 6 '06 #3
Heres the SQL I've been playing with

UPDATE [Corrective Action Subform Table]

INNER JOIN [Personnel Tbl] ON [Corrective Action Subform Table].[Person
ID] = [Personnel Tbl].[Person ID]

SET [Corrective Action Subform Table].[Person ID] = [Personnel
Tbl].[Person ID]

WHERE ((([Corrective Action Subform Table].[Person ID])=0) AND
((Left([By Whom],InStr([By Whom]," ")-1))=[Personnel Tbl].[Surname]));

This for some reason returns 0 updates, if i remove the Person ID = 0
criteria I then get a message "Invalid Procedure Call".

Dec 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8491
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
1
5152
by: Kunal | last post by:
Hi, I need some help on writing an update query to update "UnitsSold" field in Products Table whenever I save a transaction. The transaction may contain several "Subtransactions", one for each...
3
2288
by: Megan | last post by:
hi everybody- it seems like my update query should work. the sql view seems logical. but that might be up to discussion...lol...i'm a newbie! UPDATE , Issue SET .IssueID = . WHERE ((.=.));
9
2121
by: James Butler | last post by:
Our setup: Online db: MySQL Inhouse db: MS Access 97 with MySQL tables linked via ODBC Our issue: Almost every field updates successfully, except one. A scenario: Information is written to...
8
3690
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
6
10716
by: Sparticus | last post by:
I have a database that isn't very big. It has about 2400 rows in it. I try and do an update like this one below (it looks big, but it's really not if you look at it) : UPDATE jobs SET...
6
2593
by: Tom Allison | last post by:
I seemed to remember being able to do this but I can't find the docs. Can I run a sql query to insert new or update existing rows in one query? Otherwise I have to run a select query to see if...
9
4373
by: P3Eddie | last post by:
Hello all! I don't know if this can even be done, but I'm sure you will either help or suggest another avenue to accomplish the same. My problem may be a simple find duplicates / do something...
5
2243
by: Chris Cowles | last post by:
I use an application that uses Oracle 8.1.7. All functions of the application are completed with calls to stored procedures. A data entry error occurred that caused thousands of records to be...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.