views:

33

answers:

1

I'm in the process of normalizing a few tables and I've added a surrogate primary key to a table called Exams which holds exam titles.

Previously, the child tables would just use the entire name of the exam as the FK entry.

Now that I've added a autonumbered field to the table, I want to update the entries that use it such as the table where the questions are from as there are over a thousand of them.

Going through each exam with a modified update once I find the name each time would take a while, so I decided to write a correlated subquery in a UPDATE query. The query looks like this:

UPDATE tblExamQuestion
SET ExamID = (SELECT ExamID FROM tblExam WHERE ExamName = tblExamQuestion.ExamName);

Unfortunately, once I write the subquery portion, Access refuses to give me the Run option and just displays the Design View, Datasheet View and SQL View for that query. However, it still displays the Update Query icon in the object explorer.

Is there a proper way to write this so that Access doesn't get upset?

Using: Access 2007 with a Access 2003 MDB database.

+2  A: 

Why not:

UPDATE tblExamQuestion
INNER JOIN tblExam 
ON tblExam.ExamName = tblExamQuestion.ExamName
SET tblExamQuestion.ExamID = tblExam.ExamID 
Remou
Still doesn't work. Did it work in your Access application?
Nitrodist
Yes, it does. You should check your indexes to see if you have set a unique index on ExamID in tblExamQuestion. If that is not the problem, what error message do you get?
Remou
No error message, just the same thing as before -- no `Run` button. Here's a screencap with all the relevant information. http://imgur.com/k1Tly.png See anything missing?
Nitrodist
Click on the Design tab, that is where the run button lives.
Remou
http://imgur.com/ya4eZ.png
Nitrodist
Not design view, the design tab on the ribbon. The view you posted is on the Home tab.
Remou
Oh, brilliant. XD Now I know *another* quirk about Access! Thanks for the help.
Nitrodist