Link to home
Start Free TrialLog in
Avatar of TheFunkSoulBrother
TheFunkSoulBrother

asked on

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.
Avatar of rockiroads
rockiroads
Flag of United States of America image

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
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial