Click a record in the datasheet and the corresponding record in...

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

Guest

I am trying to write codes that when a user clicks a record in a datasheet in
a subform, and the matching record will pop up.

I will appreciate anyone who can give me a hand.

Best regards

SC
 
Your datasheet is based on a form.
In the form you can trigger the oncurrent event.

In the on-current event place your code. Something like:

docmd.openform "myform",,,"id-field=" & me.idfield
 
sc said:
I am trying to write codes that when a user clicks a record in a datasheet in
a subform, and the matching record will pop up.


You'll need to use some VBA code in the subform's Current
event.

If you want to open another form to the same record in the
datasheet subform:

On Error Resume Next
DoCmd.Close acForm, "otherform"
On Error GoTo ????
DoCmd.OpenForm "otherform", , ,"keyfield=" & Me!keyfield

If you want the main form to navigate to the same record:

With Me.Parent.RecordsetClone
.FindFirst "keyfield=" & Me!keyfield
If Not .Nomatch Then
Me.Parent.Bookmark = .Bookmark
End If
End With
 
If the datasheet and the form are the same then all you need to do is place
the following in the Form_Click event

RunCommand acCmdSubformFormView
 
Back
Top