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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Rey Obrero (Capricorn1)Commented:
what are the actual names of the
main form
subform
subform control
0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

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
Rey Obrero (Capricorn1)Commented:
try this

call Form_CatWebWork2SummaryF.GoToId (540)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael CarrilloInformation Systems ManagerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.