2

I am working on a database in MS Access 2013 which has a considerable amount of non-normalised data, and I want to move them out to alternate tables and use them as lookups in the main table. However, when I create a lookup column, MS Access deletes the data and there is far too much data to reset every record by hand.

Is there a way in Access 2013 to create such a lookup without losing the data?

Please don't comment about how using lookup tables in Access is bad. I have read posts like the one below and I disagree with most of the points there, and some of them are just simply wrong.

http://access.mvps.org/access/lookupfields.htm

Below is a sample of my data. I need to extract the 2nd and 3rd fields to other tables. If I can do this with them, I can do it with the others.

enter image description here

Presently this is stored as text in the fields. I would like to remove them and replace them with FK id's.

4

1 回答 1

1

您可以创建第二个表并将数据添加到表中。然后更新第一个表以使记录相互匹配

假设您有下表:

CustOrders
ID       Customer     DateOrdered
123      K-Mart       01/01/2013
124      K Mart       01/05/2013
125      Walmart      02/05/2013
126      Walmart      03/07/2013
127      Miejers      03/11/2013
128      K-Mart       03/12/2013

您可以通过执行以下操作找出表Customers中的所有内容:CustOrders

SELECT DISTINCT Customer From CustOrders

然后在下表中为每个创建一条记录:

Customers
ID       Customer
1        K-Mart
2        Walmart
3        Miejers

然后您可以CustOrders通过执行以下操作来更新表:

UPDATE CustOrders SET Customer = 1 WHERE Customer = 'K-Mart' OR Customer = 'K Mart'

当然,您必须为您拥有的每个不同的客户执行此操作。

然后,如果您愿意,可以将表中Customer字段的数据类型更改为.CustOrdersLong Integer

最后,我将在具有以下内容的任何条目/编辑表单上创建一个组合框RowSource

SELECT ID, Customer FROM Customers ORDER BY Customer

将组合框设置为从列表中限制并绑定到第 1 列。

于 2013-10-28T00:43:37.027 回答