PDA

View Full Version : Update One Table Value Based On A Value From Another Table



brorick
10-16-2009, 10:02 PM
I have a two tables(tblMain and tblTemp) with the same values. They both contain the following fields.

Table: tblMain
ID Product GroupID
1 WidgetA AAA
2 WidgetB AAA
3 WidgetC AAA
4 WidgetD GGG
5 WidgetE GGG
6 WidgetF BBB
7 WidgetG BBB


The tblTemp contains the exact fields and data except, GroupID is blank.

I plan to have a list box which contains the GroupID's in tblMain. I then can select the GroupID's I need. Then I want to search through tblMain and locate the ID associated with the GroupID and then locate the same ID's in tblTemp and update each identified Widget Group ID with the same corresponding Group ID from tblMain.

I thought initially I would create a recordset based on an Inner Join. That is not turning out so well. Anyone have any idea on how to approach this challenge. :think:

OBP
10-17-2009, 05:34 AM
brorick, what you are doing with 2 identical tables with the same data goes against Database Design Principles.
However you should be able to do what you want using an Update Query.

brorick
10-18-2009, 06:03 AM
OBP, thank you for your response. You are correct about the 2 identical table layout, but I am using only one as a Temp table which is created, updated, and then deleted. The Update Query did in fact work for me. Thanks again.