Form/Subform in two separate forms

RCopeland

Registered User.
Local time
Today, 13:09
Joined
May 22, 2012
Messages
21
Hello, I am wondering about forms and subforms. I know that you can put a subform in either a datasheet view or form view on a main form, but I personally dislike the way this looks and feels. Here is my solution in theory:

I have a main form, Customers that is used for entering new records into a Customers Table. This Customers Table is related to a Contract Table with a 1-to-many relationship (1 Customer to many Contracts). I would like to create two separate forms: Customers, for entering 1 customer record and then by pressing a button takes me to a separate form where I can enter many contract records. The problem is that I cannot figure out how to make the second form only able to add new Contracts to the previously added Customer from the previous table.

I have tried setting the second forms CustomerID field (Foreign Key to the Customer Table) to a default of the last record in the Customer Table on open, but when trying to save the new Contract record I receive an error that this record cannot be saved due to "The current field must match the join key '?' in the table that serves as the 'one' side of one-to-many relationship."

Can anyone help me out? TIA!
 
When opening the second form, use the OpenArgs property of the Docmd.openForm method to pass the CustomerID from the first form
 

Users who are viewing this thread

Back
Top Bottom