Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Location
    Oakland, CA
    Posts
    126

    Unanswered: Function OpenForm

    Hi, instead of typing a subprocedure to open a form zillion times I decided to write a function to which I would pass a value (a form name) and the form would open. So this is the function:

    Function OpenForm(FormName As String)

    DoCmd.OpenForm FormName
    DoCmd.Maximize

    End Function

    Now, on another form I have a button where in the Event "On Click" I typed OpenForm (frmMain) and was hoping for the function to kick in and open the frmMain.
    Instead a got an error message that DB can't find macro OpenForm(frmMain). Anybody can help?

  2. #2
    Join Date
    Feb 2004
    Posts
    142

    Re: Function OpenForm

    Originally posted by vojtab
    Hi, instead of typing a subprocedure to open a form zillion times I decided to write a function to which I would pass a value (a form name) and the form would open. So this is the function:

    Function OpenForm(FormName As String)

    DoCmd.OpenForm FormName
    DoCmd.Maximize

    End Function

    Now, on another form I have a button where in the Event "On Click" I typed OpenForm (frmMain) and was hoping for the function to kick in and open the frmMain.
    Instead a got an error message that DB can't find macro OpenForm(frmMain). Anybody can help?
    Declare the function public (I assume that is in a general module).

    Public function OpenForm(formName as string)

    It would probibly be wise not to name a function the same as a method call.
    KC

  3. #3
    Join Date
    Nov 2002
    Location
    Oakland, CA
    Posts
    126
    I agree with the method call, I will change that but still this doesn't seem to be the issue.

    I get the error when I call now the public function from the button. The error is that there is not such macro even though this is a module. I must be doing something wrong

  4. #4
    Join Date
    Nov 2002
    Location
    Oakland, CA
    Posts
    126
    Got it, I wasn't just typing = in the event. Thanks all for help

Posting Permissions

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