I have a main form called Assets, which shows one Asset at a time, and two continuous subforms.
The second subform is called Asset_Groups. Its purpose to to show all other assets which share the same Group value as the active record in the Parent form.
The Asset_Groups form uses the same table as the main form. Its Parent and Child fields are both set to Group. As I move from one Asset to another in the parent form, the Asset_Groups subform correctly shows all related assets for the active asset in the parent form.
When viewing assets in the Asset_Groups subform, I want to be able to select one and have it become the active record in the parent form. So I set up a Double Click Event for the BarCode field in the subform to perform that task. But I guess I don't know how it should be coded, as it doesn't work right. It just takes me to the first record in the table.
Code:
Private Sub BarCode_DblClick(Cancel As Integer)
Dim Rec_ID As Integer
Rec_ID = Me.[ID]
DoCmd.OpenForm "Assets"
DoCmd.GoToRecord acDataForm, "Assets", acGoTo, Rec_ID
Me.Parent.Requery
End Sub
First of all, I don't know why it complains if I do not explicitly open the parent form, as it is already open.
I figure I must be headed down the wrong coding path. See screen print of the forms, which shows the Group field in the Parent form and in the child form and the BarCode field in the child form, for which the Double Click Event Procedure is coded.
Please ignore the second image. I don't know how it got there and I cannot figure out how to get rid of it. Sorry.