Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2007
    Posts
    40

    Unanswered: Scope of procedures declared public?

    I have a subform which contains various input boxes for the purposes of conducting a search. The reason why this is implemented as a subform is that the same search mechanism is used in various places within the application. In order to perform the search itself, I have a sub within the form's module, called DoFind, which is declared public as follows:

    Code:
    Public Sub DoFind()
      ' {code to perform the find}
    End Sub
    Now from another form module I want to call the find method, for example in the Click method of a find button. So I have something like this:

    Code:
    Private Sub btnFind_Click()
      DoFind
      ' {code to process the find}
    End Sub
    However I get "Compile error: Sub or Function not defined" for DoFind.

    How can I get the DoFind procedure into scope for the btnFind_Click() procedure? I thought of declaring it in a standard module, but didn't really want to do that because the variables it accesses are from controls on the actual form itself.

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Try this
    Code:
    Private Sub btnFind_Click()
      Form_YourFormname.DoFind
      ' {code to process the find}
    End Sub
    Where YourFormname is the name of the form with the public sub DoFind

    Public delcarations in Class Modules (which is what a form is) are access as a method of the class (as I understand it!).


    MTB
    Last edited by MikeTheBike; 07-20-07 at 08:56.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by MikeTheBike
    Public delcarations in Class Modules (which is what a form is) are access as a method of the class (as I understand it!).
    You understand it spot on - I was ready to post the same
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jun 2007
    Posts
    40
    Thanks, that worked like a charm.

    Quote Originally Posted by MikeTheBike
    Hi

    Try this
    Code:
    Private Sub btnFind_Click()
      Form_YourFormname.DoFind
      ' {code to process the find}
    End Sub
    Where YourFormname is the name of the form with the public sub DoFind

    Public delcarations in Class Modules (which is what a form is) are access as a method of the class (as I understand it!).


    MTB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •