Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Unanswered: Passing Form to other forms

    This is a simplified example of what I want to achieve.
    I have a form (frmMain) containing 1 button (command1).

    When clicking the button I do following :

    Code:
    private sub command1.Click()
       call modForms.setClickedForm (Me)   --> GIVES ERROR
    end sub

    I made a module (modForms) with 2 methods :

    Code:
    Dim selectedForm as Form
    
    ********************
    
    Public Sub setClickedForm(clickedForm As Form)
         Set selectedForm = clickedForm
    End Sub
    
    ********************
    
    Public Function getClickedForm() As Form
        Set getClickedForm = selectedForm
    End Function
    
    ********************
    Meaning is to make frmMain accessible from within every module I want.
    Just by calling the 'getClickedForm'-function.

    It looks good to me, but my computer doesn't agree.
    It always says 'Error 13 : Types don't match" .

    What is wrong?

    Thanks

  2. #2
    Join Date
    Jan 2003
    Location
    Vietnam
    Posts
    188

    Re: Passing Form to other forms

    Originally posted by artemide
    ********************

    Public Sub setClickedForm(clickedForm As Form)
    Set selectedForm = clickedForm
    End Sub

    ********************

    Public Function getClickedForm() As Form
    Set getClickedForm = selectedForm
    End Function

    ********************
    [/code]


    Thanks
    could you try "As Object" wherever "As Form"?

    hope this helps
    qha_vn

  3. #3
    Join Date
    Jun 2003
    Posts
    1

    Re: Passing Form to other forms

    Originally posted by artemide
    This is a simplified example of what I want to achieve.
    I have a form (frmMain) containing 1 button (command1).

    When clicking the button I do following :

    Code:
    private sub command1.Click()
       call modForms.setClickedForm (Me)   --> GIVES ERROR
    end sub
    I don't know if this is any help, but I was trying to pass a form object to another function and kept getting errors, then I removed the parentheses from where I call the function (from (Me)) and everything worked fine.

  4. #4
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Passing Form to other forms

    Originally posted by Bagpuss
    I don't know if this is any help, but I was trying to pass a form object to another function and kept getting errors, then I removed the parentheses from where I call the function (from (Me)) and everything worked fine.
    I removed the parentheses and guess what .... it works.
    I only spend half a day working on this issue without any result.
    And the solution is that simple.

    Thanks a lot.

Posting Permissions

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