I have a few tables linked together. When I have a subform with info from one table, access automatically populates the linked field in the subform to match the main form. However, in my case I have three tables linked and I want one table to be in the main form and then data from the second and third to be on one subform. My subform is based on a query which includes data from the 2 and 3 table. However when I go to the Subform, the linked field is not populated. As a workaround, I simply enter the data in this field to match the main form and can enter the rest of the data on the subform and all is well. However to save some time, I would like to populate this field with VBA when I click on the new record command button I created but I can't get the syntax correct.
Main Form is called FClient and Table is called Client Linked field is Customer ID
Sub Form is called FLicense_Detail
I tried the following different codes but I don't know the correct syntax. Any help is appreciated
Private Sub New_Click()
DoCmd.GoToRecord , , acNewRec
Me.CustomerID = [Forms]![FClient]![CustomerID]
End Sub
Private Sub New_Click()
DoCmd.GoToRecord , , acNewRec
Forms("FLicense_Detail").CustomerID = [Forms]![FClient]![CustomerID]
End Sub
Private Sub New_Click()
DoCmd.GoToRecord , , acNewRec
Me.CustomerID = CustomerID.Value
End Sub
Thanks,