Create a new lookup table where data already exists

♀尐吖头ヾ 提交于 2019-12-04 16:54:32

You could create your second table and add the data to the table. Then update the first table to match the records to each other

Let say you have the following table:

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

You could find out all of the Customers that are in the CustOrders table by performing the following:

SELECT DISTINCT Customer From CustOrders

Then create a record in the following table for each:

Customers
ID       Customer
1        K-Mart
2        Walmart
3        Miejers

Then you could Update the CustOrders table by performing the following:

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

Of course you would have to do this for each distinct customer you have.

Then if you want you could change the data type of the Customer field in the CustOrders table to Long Integer.

Lastly I would create a combo box on any entry/edit form that has the following RowSource:

SELECT ID, Customer FROM Customers ORDER BY Customer

Set the combo box to limit from list and bind to column 1.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!