auto populate related (foreign) key fields in other Access tables

J

Jenni A Chambers

Using Access 2007. How do you automatically populate linked child tables with
a matching key value. For instance, a customer has details and an order. The
customer details table has an auto key generated. This is used to add a
customer order which has a key of customer number and order number. How do I
get the automatically generated customer number from the customer details
table into the customer number field on the customer order table when linking
via a button on the customer details form to the customer order form?
 
T

Tom Wickerath

Hi Jenni,
This is used to add a customer order which has a key of customer
number and order number.

I'm not sure why you need a combined field key (primary key?) in this case.
You could use an autonumber primary key, with the customer number as a
foreign key.

If the customer order form is a separate form (ie. not a subform), then one
way of doing this is to pass the CustomerID to the order form using the
optional OpenArgs argument. VBA code in the load event procedure for the
customer order form is used to read the optional OpenArg value, if it was
passed to this form. You can then use that value to set the appropriate
field, if this form was opened to a new record.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

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