Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting wrong key back after some trigger inserts (MSSQL backend)

Status
Not open for further replies.

TheBlueDog

Technical User
Aug 23, 2002
13
US
Desperate for some keen advice here. I am inserting rows on a multi-row form into table A. Table A is a SQL table which then either inserts a row into Table B or updates an existing row in Table B. An insert/update trigger on Table A manages this process. Unfortunately, when the trigger must cause an insert into Table B, the wrong identity key gets returned to my Access interface, which then displays the "inserted row" from Table A wich matches the key value from Table B. I can see in SQL trace the @@identity value getting returned to the interface, and I guess the last key inserted was the one on Table B, so that value is getting passed back. Does anyone know any good way around this, short of abandoning identity keys on my tables (heaven help me then!)? BTW, I used to do this all the time safely in Access 97 with SQL 6.5, but since I have (finally) moved into the new millenium this problem seems to have started somewhere in Access 2000/SQL 2000.

Oh, I have also tried 3 ODBC drivers but all produce the same result.

Thanks to any hero who can help me resolve this.
-KG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top