Calling a method in a subform

Posted on 2006-05-30
Last Modified: 2009-07-23
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
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.
Question by:TheFunkSoulBrother
    LVL 65

    Expert Comment

    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
    LVL 65

    Accepted Solution

    calling it seems fine

    try this

    mySubForm.Form.JumpToRecord 4

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now