Calling a method in a subform

Hi experts,

I've got the subform "mySubForm" in "myMainForm".
And in mySubForm there is the following function:

Public Sub JumpToRecord(rec_id As Long)
  DoCmd.GoToRecord , , acFirst
  While myID.Value <> rec_id And Not IsNull(myID.Value) And Not myID.Value = ""
      DoCmd.GoToRecord , , acNext
  Wend
End Sub

But calling JumpToRecord from myMainForm doesn't work.

mySubForm.Form.JumpToRecord 4  -->  Runtime error 2105

Me.Controls("mySubForm").Form.JumpToRecord 4  ... doesn't work either.

Dim obSubform As Form_Plan
Set obSubform = Plan.Form
obSubform.GotoPlan 4 ... same problem


Runtime error 2105 means ~ You can't jump to the record.
But I'm sure the record with myID=4 exists.
LVL 1
TheFunkSoulBrotherAsked:
Who is Participating?
 
rockiroadsCommented:
calling it seems fine

try this

mySubForm.SetFocus
mySubForm.Form.JumpToRecord 4
0
 
rockiroadsCommented:
Is the procedure u defined public?

Have u tried doing a setfocus so focus is on that child window, then DoCmd.Goto knows which form to work on
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.