View Main Modal form based on chosen subform record

kilburfi

Registered User.
Local time
Today, 10:09
Joined
Jun 4, 2013
Messages
34
I have a modal form which has a single record which is then linked to a sub-form on the same modal form. This all works fine and shows the relevant record and sub records but I want the modal form main record to change dependant on the record selected in the subform (which is basically order item history.

I found some code on another site which seemed to work for others but for me I am getting Run-time error 2465 and it doesn't like my reference to 'Me' - is this because it is a modal form?

The code I am using is:

Public Function GotoRecord(RecordID As Long)

Dim rst As DAO.Recordset
Dim strCriteria As String

Set rst = Me.RecordsetClone
strCriteria = "ID = " & RecordID
rst.FindFirst strCriteria
If rst.NoMatch = False Then
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing

End Function

and calling it with:

Private Sub Form_Current()

Call Me.Parent.GotoRecord(Me.ID.Value)

End Sub

Any ideas?
 
I have solved this now as I didn't have the function in the right place (should have been with the parent form).
 

Users who are viewing this thread

Back
Top Bottom