Reputation: 79
I have two tables in a 2010 Access Database. One for Customers and One for Invoices. I created a form with a lookup field at top for a new invoice.
What I'm trying to do is when you look up a customer and choose them, their information will automatically populate into the customer information on the invoice field (so you don't have to retype it). It would then have to copy over to the invoice table when you save.
I'm assuming this requires a one to many relationship? It seems like this is a pretty basic step but having a tough time finding the answer any help would be greatly appreciated :)
Upvotes: 0
Views: 1273
Reputation: 24207
You'll want to set up your tables like this:
Customers
Invoices
Then on your form you will want to use your Invoices table (primarily) for the form Recordsource:
SELECT ID, CustName FROM Customers ORDER BY CustName
The user will then choose a customer to associate with an invoice from the combobox (pulldown). There are no fields to copy. When you want the customer info for an invoice you just join the customer table with the invoice table like so:
SELECT Customers.*, Invoices.*
FROM Invoices INNER JOIN Customers ON Invoices.CustomerID = Customers.ID
Note that I've used the asterisks for simplicity in the example. It's good practice to explicitly specify which columns you want to use in a SELECT query.
Upvotes: 1