Can someone help me correct my code to get Access form to autopopulate?

By bacarley ·
I'm sorry if this is overly complicated, but I know just enough to be dangerous... I am trying to fomat an Access pop-up form so that the vendor/customer name, number and ID autopopulate based on the information in the current input form. The form opens with these fields blank.

My tables are:

Vendor Data and Coverages

The Vendor Input and Additional Insured forms are used to populate the Vendor Data table. The Coverage Input form is used to populate the Coverages table. I have a one-to-many relationship established between the Vendor Data table and the Coverages table.

Entering information in a certain field in the Vendor Input form causes the Additional Insured form to pop up using the following code:

Private Sub COI_AfterUpdate()

DoCmd.OpenForm "Additional Insured", , , "[ID]=" & Me.ID

End Sub

When the input on this form is completed and closed, it opens the Coverage Input form using the following code:

Private Sub Alternate_Exit(Cancel As Integer)

DoCmd.OpenForm "Coverage Input", , , , "[ID_Vendor Data]=" & Me.ID

End Sub

The Coverage Input form is used to input each type of insurance coverage for each vendor and, therefore, multple records will be input for the vendor/customer. At the end of this form, tabbing should create a new record with same vendor data, linked to that vendor.

The relevant fields in the Additional Insured form are:

ID (primary autonumber key in Vendor Data table) - autopopulates on form open from main Vendor Input form
VendorNumber - autopoulates on form open
Name - autopopulates on form open

The fields in the Coverage Input form which I would like to autopopulate and be linked to the existing open record in the Vendor Input (and Additional Insured) form are:

Name (from the Vendor Data table)
VendorNumber_Vendor Data (from the Vendor Data table)
ID_Vendor Data (from the Vendor Data table)

The Coverages table has the following relevant fields:

ID (primary autonumber key)
VendorID (lookup field primary relationship link to Vendor Data "ID" field)

Currently the Additional Insured form opens and autopopulates as desired. The Coverage Input pop-up form opens on exit from the last field in the Additional Insured pop-up, but the fields are blank (except [New] in ID_Vendor Data field) and any information input is not associated with the vendor record.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums