Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Operation Must Use an Updateable Query

Author  Topic 

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-06-25 : 18:06:14
I'm doing a data conversion project within Access 2000. I'm trying to update a table named Person and I'm getting the message that "Operation must use an updateable query." But I'm trying to update a table not a query, although I'm using a query in the process. All my Google searching seems to assume I'm updating a query when I enter the error message. ARRRGGGHHHH!!!

Any help appreciated. Here's the statement (in an UPDATE QUERY) that is generating the error:
UPDATE Person 
SET TeamLeaderId =
(SELECT LeaderPersonID
FROM DBRES_Person_TeamLeader_IDList
WHERE Person.PersonID = DBRES_Person_TeamLeader_IDList.PersonID
);

And the contents of DBRES_Person_TeamLeader_IDList are:

SELECT [TBL_EC Specialists].[Last Name], [TBL_EC Specialists].[First Name],
[TBL_EC Specialists].[Team Leader], P1.PersonID, P2.PersonID AS LeaderPersonID
FROM ([TBL_EC Specialists]
INNER JOIN Person AS P1 ON
([TBL_EC Specialists].[First Name] = P1.FirstName)
AND ([TBL_EC Specialists].[Last Name] = P1.LastName))
INNER JOIN Person AS P2 ON
([TBL_EC Specialists].[Team Leader]) = (P2.LastName & ', ' & P2.FirstName)
WHERE ((([TBL_EC Specialists].[Team Leader]) Is Not Null));


Have I mentioned how much I love Access lately? No? I thought not.

[edit]Modified Formatting[/edit]
-----------------------------------------------------
Words of Wisdom from AjarnMark, owner of Infoneering

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2004-06-25 : 23:33:06
Access is a pain.

Have you tried dropping all the relationships to the table
Creating the entire records you want to update in a separate table
deleting the records you want updated
Inserting the new records
recreating the relationships.
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-06-26 : 04:41:30
Does Access even support co-related subqueries in an UPDATE? Maybe you should try running the update using an INNER JOIN - does this work?:

UPDATE Person
SET TeamLeaderId = LeaderPersonID
FROM DBRES_Person_TeamLeader_IDList
INNER JOIN Person
ON Person.PersonID = DBRES_Person_TeamLeader_IDList.PersonID
;


OS
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-06-28 : 00:51:40
OS, I had tried that idea too and it wasn't working. UNTIL... I went through the (otherwise irritating) design screen letting it build the SQL statement for me and discovered that you have to put all of the joins, etc. BEFORE the SET statement, as if it's all one big table. So, I got it to work now, and the working version reads as:

UPDATE ([TBL_EC Specialists] 
INNER JOIN Person AS P1
ON ([TBL_EC Specialists].[Last Name] = P1.LastName)
AND ([TBL_EC Specialists].[First Name] = P1.FirstName))
INNER JOIN Person AS P2
ON ([TBL_EC Specialists].[Team Leader]) = (P2.LastName & ', ' & P2.FirstName)
SET P1.TeamLeaderID = P2.PersonID;


And for the record, y'all will notice that two of the things I'm getting rid of in this restructuring project are the TBL_ prefixes and the spaces in table and field names.

-----------------------------------------------------
Words of Wisdom from AjarnMark, owner of Infoneering
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-06-28 : 04:55:56
quote:
Originally posted by AjarnMark

And for the record, y'all will notice that two of the things I'm getting rid of in this restructuring project are the TBL_ prefixes and the spaces in table and field names.

Good luck with that!

When we have a Better Idea in development I have a couple of tables called ColumnMigration and TableMigration which have the Old and New names in them and use this to create VIEWs under the original names referencing the New Tables/Columns. This allows for some piecemeal conversion but being able to script the generation of the VIEWs as often as needed.

Kristen
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-06-28 : 17:08:51
Kristen, that sounds like a good approach if you're not able to do a complete replacement. I'm fortunate in this project that I'm doing a total restructuring and we will shut everything down for a day and run the data conversion scripts, and plug in the new front-end and reports. Start it up at the end of the day and it will all work perfectly! (Riiiiight...)

This total restructuring is actually phase 1 of the project, getting it ready to be moved out of Access and into Oracle with probably a JSP front-end. But the original system (which I did NOT write) is so convoluted that we're taking it in two phases: Restructure within same technology and then once that's proven, port to different technology.

-----------------------------------------------------
Words of Wisdom from AjarnMark, owner of Infoneering
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-06-29 : 10:17:05
We rarely manage to impliment a Better Idea in one step, so have to have VIEWs for legacy stuff to keep connected. We're now at the stage where we have a VIEW with the name of the original talbe: "MyTable", and the table itself is now at version 3 - so "MyTable_V3" and a view called, you guessed it!, "MyTable_V2" that covers for the stuff wanting to connect to the system with how the database was "last time around".

Now the people who are using the original table, ermmmm ... I mean VIEW!, are asking to have access to the latest columns, but they don't want to change the application where they don't have to, so now the view "MyTable" has the additional columns added in V2 and V3. Ho Hum!

Who do I shoot first? Heads it's me ...

Kristen
Go to Top of Page
   

- Advertisement -