I have a form "AccountInf o" that contains company names. I have
inserted a subform "Contacts" with contact names and have established
parent/child relationships between the two forms. All works well.
I created an "Add New Contact" command button which passes the
CompanyID (unique key set to autonumber) to the new record. This
successfully works if the parent record (AccountInfo) has at least one
existing contact. But if there are no contacts associated with the
AccountInfo record, I get the error "Applicatio n-defined or
Object-defined error" when I click the Add New Contact command button.
This happens because the Contact form CompanyID doesn't have a number
yet---the number is "autonumber ".
This is the code I am using:
DoCmd.OpenForm "AddContact ", DataMode:=acFor mAdd
Forms("AddConta ct").CmpnyID = Me.CompanyID
How do I pass the parent form CompanyID to the 'Add New' child form?