Goto record on master form based on subform selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a little coding help here.

I have a datasheet subform based on the same table as the master. The
Master form is just a Single Form where edits can be made or new records
created. The sub form is "tbl_Trace subform"... I know quit wincing at my
poor naming convention.

I want the OnClick event in the subform on field [trace_ID] to make the
master form go to that record.

Thanks in advance
 
Bdavis said:
I have a datasheet subform based on the same table as the master. The
Master form is just a Single Form where edits can be made or new records
created. The sub form is "tbl_Trace subform"... I know quit wincing at my
poor naming convention.

I want the OnClick event in the subform on field [trace_ID] to make the
master form go to that record.


If the table's primary key is included in the subform's
record source table/query, then you can use code like this
in the subform's Current event:

With Me.Parent.RecordsetClone
.FindFirst "Trace_ID = " & Me.Trace_ID
Me.Parent.Bookmark = .Bookmark
End With
 
I had a similar problem in another thread and found this solution.

It locates the current record number in the subdatasheet view, opens the
parent form in form view, and then tells the parent form to goto the record
that was in the datasheet view.

Private Sub trace_ID_OnClick(Cancel As Integer)
Dim lngrecordnum As Long
lngrecordnum = Me.CurrentRecord

DoCmd.OpenForm "tbl_TraceParentFormName", acNormal
DoCmd.GoToRecord acDataForm, "tblTraceParentFormName", acGoTo,
lngrecordnum
End Sub


Marshall Barton said:
Bdavis said:
I have a datasheet subform based on the same table as the master. The
Master form is just a Single Form where edits can be made or new records
created. The sub form is "tbl_Trace subform"... I know quit wincing at my
poor naming convention.

I want the OnClick event in the subform on field [trace_ID] to make the
master form go to that record.


If the table's primary key is included in the subform's
record source table/query, then you can use code like this
in the subform's Current event:

With Me.Parent.RecordsetClone
.FindFirst "Trace_ID = " & Me.Trace_ID
Me.Parent.Bookmark = .Bookmark
End With
 
Back
Top