从查询查询更新查询

问题描述:

我有一个电子表格,正在将其转换为Access DB.我有一列输入的客户名称,我想用我们会计系统中的相应客户编号替换.

I have a spreadsheet that I am converting to an Access DB. I have a column of typed out customer names that I want to replace with the appropriate customer number from our accounting system.

我创建了一个包含客户信息的表,以及一个查询,该查询显示了需要在源数据中插入哪些ID.我正在寻找的是:

I have created a table with the customer info, and a query that shows what ID needs to be inserted into the source data. What I'm looking for is:

UPDATE tblStarting_Data
SET CustomerID=x
WHERE TEMPCustomer=y

X和Y来自qryIDPerCustomer.

Where X and Y come from qryIDPerCustomer.

我可以使用循环吗?如何引用另一个查询?

Can I use a loop? How do I reference another query?

MS Access中的另一种可能性(从Tomalak答案中借用的对象名称):

Another possibility in MS Access (object names borrowed from Tomalak answer):

UPDATE tblStarting_Data, qryIDPerCustomer
SET tblStarting_Data.CustomerID=qryIDPerCustomer.CustomerID
WHERE tblStarting_Data.TEMPCustomer=qryIDPerCustomer.CustomerName