Access VBA call subroutine that is in a subform

I created a subroutine that is located in a subform.
What's the syntax to call it from another [unrelated] form? I've tried everything I could think of.

Forms!MainForm!Subform.Form.GoToId (540)
LVL 10
etech0Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
try this

call Form_CatWebWork2SummaryF.GoToId (540)
0
 
Rey Obrero (Capricorn1)Commented:
what is the sub routine ? post it here

make the sub Public instead of Private
0
 
etech0Author Commented:
Public Sub GoToId(ByVal RecID As Integer)
Dim rs As dao.Recordset

' set it to a clone of the form's recordset so that whatever you do doesn't affect the form just yet
Set rs = Me.RecordsetClone

rs.FindFirst "[id]=" & RecID

' if there's a match, set the form's bookmark to that of the rs' bookmark
If Not rs.NoMatch Then
    Me.Bookmark = rs.Bookmark
End If

Set rs = Nothing
End Sub
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Rey Obrero (Capricorn1)Commented:
what are the actual names of the
main form
subform
subform control
0
 
etech0Author Commented:
CatWebWork2F
CatWebWork2SummaryF

What control? The ID field is called ID.
0
 
etech0Author Commented:
The macro is in CatWebWork2SummaryF, and I'm trying to call it from another form entirely.
0
 
macarrillo1Commented:
I would remake this subroutine into a public subroutine in your code module. Then call as needed.

Public SubGoToId(ByVal RecID As Integer, fName as object)

' set it to a clone of the form's recordset so that whatever you do doesn't affect the form just yet
Set rs = fName.RecordsetClone

rs.FindFirst "[id]=" & RecID

' if there's a match, set the form's bookmark to that of the rs' bookmark
If Not rs.NoMatch Then
    fName.Bookmark = rs.Bookmark
End If

Set rs = Nothing
End Sub
0
 
etech0Author Commented:
Whew - thanks!
macarrillo1: interesting idea, I'll keep it in mind.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.