473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Couldn't update multitable form (3 tables)

I'm having problem updating a form that queries from 3 tables. When I
update the foreign key it tries to update the PK on the foreign key
table which it shouldn't. I'm using MS Access 2003 connected to SQL
Server 2000.

Here's an example:

Tables: T1, T2, and T3.
T1 links to T2, and T2 links to T3.

When I update the foreign key on T1 that links to T2, MS Access is
trying to update the PK of T2, instead of the foreign key of T1 which
causes data integrity error "cannot update PK on T2". T1 are the main
contents of the form. When the foreign key changes the form should also
be updates with the foreign table information.

Thanks in advance,
Benjamin

Feb 23 '06 #1
14 1907
Note, All tables are 1:1 relationship. It is normalized.

Feb 23 '06 #2
Here's an example:

select T1.*, T2.Field1, T3.Field1
from (T1 inner join T2 on T1.T2ID = T2.ID) inner join T3 on T2.T3ID =
T3.ID

I dont' understand why it would update the T2.ID, when I update T1.T2ID
field. Is this a bug in MS Access? or could I specify which table to
update somewhere?

Thanks,
Benjamin

Feb 23 '06 #3
Do you have cascade updates turned on in the relationship between the
two tables?

Jeremy
--
Jeremy Wallace
http://metrix.fcny.org

Feb 23 '06 #4
Should the cascade update be implemented on the SQL Server side? I see
the option on MS Access, but the options are disabled. BTW, I'm using
MDB with linked-tables, not ADP.

But it's tring to update T2.ID instead of the foreign key field on
T1.T2ID.

Thanks,
Ben

Feb 23 '06 #5
Let me clarify on the relationships:
T1 is 1:1 to T2, and T2 is *:1 to T3. There could be cases where T2 is
*:1 to other tables.

Feb 23 '06 #6
When I take T3 out of the picture it still does the same thing.

Feb 23 '06 #7
On the SQL Server side, I tried having the relationship:
* With and Without "Enforce relationship for INSERTs and UPDATEs"
* With and without "Cascade Update Related Fields"

Neither one works... MS Access is trying to update the identity column
of the T2, it should update T1.T2ID (foreign key column). It's weird
that it does that because in the select statement it doesn't have
T2.ID, it has the T1.ID (of the T2) which I named T1.T2ID in this
example. I wonder if that's the problem.

Hmm... Here's a more real example:
I have T1.T2ID (Foreign Key), and T2.T2ID (PK). I update T2ID on the
form, the form queries from T1.T2ID only, it doesn't selected from
T2.T2ID. When it updates, it updates T2.T2ID which is the problem. It
should update T1.T2ID. Hmmm... Maybe if I rename the foreign key column
on T1.T2ID to T1.fkT2ID it might work... I'll give that a shot.

Feb 23 '06 #8
That didn't work... renaming column T1.T2ID to T1.fkT2ID didn't work...
It's still trying to update T2. Here's the error message:

ODBC--update on a linked table 'T2' failed.
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot update
identity column 'T2ID'. (#8102)

It shouldn't update T2.T2ID.... It should update T1.fkT2ID ... that
didn't work....

Feb 23 '06 #9
Am I missing something here? I created a ADP and connect directly to
the SQL Server, created a view with those queries, and I was able to
update the T1.T2ID without any problem. But... I cannot use ADP yet, I
need to develop under MDB...

Feb 23 '06 #10
Yes! I got it working in a different way. I created a View, then create
a linked table to the view, choose the view as the datasource for the
form. And fortunately I was able to update the view (3 table join)
without additional triggers such as INSTEAD OF (Insert/Update/Delete).

Please share the information if you have solution to the problem
without using a view.

Thanks!
Benjamin

Feb 23 '06 #11
bc****@gmail.com wrote in
news:11********************@e56g2000cwe.googlegrou ps.com:

[]

Just a minor point:

Whenever I see a thread that is a cascade of a single person posting
and replying to himself repeatedly (as this thread stands currently
in my newsreader, there are 11 posts in the thread, only 1 of which
is from someone else), I ignore the thread, because it's just too
much trouble to take the cascade of messages and paste them together
into a coherent picture of the problem the question is about.

Don't post until you have all your ducks in a row and know what you
want to ask.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Feb 23 '06 #12
Benjamin,

I have to agree with David here. It's _great_ that you're taking the
time to look into this yourself and not just sitting around waiting for
someone to solve your problem. But I will say that I dropped my jaw
when I checked back in here and saw the number of posts that came after
mine (in addition to the ones before it). I'm certainly not offended
(and I didn't get the impression David was), but I do think it's best
for all if you do your digging before posting to CDMA, as you can then
present what you've done in a more coherent way, making it easier for
people to see what your question is, and what avenues you've
explored--the whole goal here is to make it interesting for people to
have a go at your problem.

In the end, it looks like you got it worked out in a way that makes a
lot of sense, which is the real point, so cheers to you on that.

Jeremy
--
Jeremy Wallace
http://metrix.fcny.org

Feb 23 '06 #13
"Jeremy Wallace" <je************@gmail.com> wrote in
news:11**********************@v46g2000cwv.googlegr oups.com:
I do think it's best
for all if you do your digging before posting to CDMA, as you can
then present what you've done in a more coherent way, making it
easier for people to see what your question is, and what avenues
you've explored--the whole goal here is to make it interesting for
people to have a go at your problem.


I start a lot more questions to CDMA than actually end up being
posted. What usually happens is I encounter a problem that I can't
solve and decide to post about it. In the process of writing the
post explaining my problem, it occurs to me that I haven't tried X
and Y, so I try those, and if they don't work, I put that in the
post. WHile writing about that, it occurs to me that I could try Z,
too, and so I try that.

About half the time, by the time I've written the post and tried the
things that hadn't occurred to me before starting the post, I've
solved the problem. It's only in the cases where I do everything I
can think of and still haven't solved the problem that the question
actually ends up getting posted at all.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Feb 24 '06 #14
Thanks for the comments. I'll keep that in mind. Actually, I have tried
a lot before I post. I'll keep that in mind next time before I post.
Sorry for the long posts :)

The reason I posted was because I had problems with updating views
before on many other forms that has multiple tables, and I didn't want
to create triggers INSTEAD OF update/insert/delete that would cause
maintenance overhead when table changes. So, I end up converting the
views to stored queries in MS Access and it works for most forms,
except for the problem I posted on this form, and I forgot to try
restoring back to SQL Server View, and I was glad it updated view fine.

But I still don't understand why MS Access is updating the PK instead
of the Foreign key. Is this a bug in MS Access? or lack of feature to
specify which table to update?

Thanks,
Benjamin

Feb 24 '06 #15

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

Similar topics

1
by: Dreamerw7 | last post by:
Hi, I know this is probably a dumb question, but here goes: I have 3 tables: REGION REG_ID REGION
3
by: Frank | last post by:
We have an Access database Sch_S.mdb in the shared driver S across the network. I have a copy of that database in my local driver C, named as Sch_C.mdb. As per users' request I added some check...
7
by: gthompson | last post by:
Is this possible: Read fields(rows/columns) from one sql database table (TableA). Then edit/update the same 'field' in TableA; and in TableB edit/update a different field - all at the same time?...
1
by: mpmason14 | last post by:
i want to update my "timesheet" form based upon a second form "add employee" whenever a new employee is added. right now the "add employee" form adds the employee to the table, but it doesn't update...
1
by: EyesFriedOpen | last post by:
I was trying to post this to the IBM DB2 forum, however I do not have the "New Post" button available when I view the IBM DB2 forum. Therefore, I apologize if this is not the right place for this. ...
4
by: Robert Bravery | last post by:
HI all, Can someone show me or point me to a place where I can find out how to update dbase(dbf) tables. Thanks RObert
3
by: MyWaterloo | last post by:
Heya... Thanks in advance if you can help... or at least understand my gibberish. I have 2 tables, let's call them tblBacT and tblBacTData, they are related through the auto number primary key...
0
by: koskap | last post by:
Hello . I have three related tables (Team, driver, points). The problem that i have is that i can't update all three tables at the same time. The error says that a record is required in the table...
4
by: Big P | last post by:
I need to update a form everytime a button is clicked. My form has more than 20 buttons. So need i to find out what is the best event to do that. I am new to VB Express and now i have the time...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.