SQL lookup

J

jrcapitosti

How or where do I use a SQL lookup to retrieve the [Company] field
from the Northwind dbase by the [Customer ID] field via the Orders
table?

I don't know where to start and would appreciate any guidance
available.

Thank you
 
K

Ken Sheridan

In a form based on the Orders table use a combo box bound to the CustomerID
field, setting up its properties as follows:

ControlSource: CustomerID

RowSource: SELECT CustomerID, CompanyName FROM Customers ORDER BY
CompanyName;

BoundColum: 1
ColumnCount: 2
ColumnWidths 0cm;8cm

If your units of measurement are imperial rather than metric Access will
automatically convert the last one. The important thing is that the first
dimension is zero to hide the first column and that the second is at least as
wide as the combo box.

In a report use a query as the report's RecordSource. In the query join the
Orders and Customers table on the CustomerID columns. You can then bind a
text box control in the report to the CompanyName column, or indeed any
column from the Customers table you might want to include in the report.

While you can also use a combo box as the display control in a table, and
the Northwind database does this for the CustomerID column in the Orders
table, I'd recommend against it. Data should only be viewed in forms or
reports in any application worth its name, not in raw datasheet view, so its
better to leave a table design to show the actual stored values in datasheet
view and not confuse the issue by showing values looked up from another table.

Ken Sheridan
Stafford, England
 
I

iratxe

How or where do I use a SQL lookup to retrieve the [Company] field
from the Northwind dbase by the [Customer ID] field via the Orders
table?

I don't know where to start and would appreciate any guidance
available.

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top