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

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
 
G

Guest

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
 
M

Marshall Barton

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top