Running Method Button in one form from another form.

  • Thread starter Thread starter Jade
  • Start date Start date
J

Jade

I am trying to design a button in one form that opens
another form and executed a button method within that form.

I want to button to open a form based on a different table,
then execute the code connedced with a cmdNew_Record button
in the second form. This command shows several hidden
buttons and instructions, as well as opening a blank record.

I have tried a line "Runcommand acRunCmd..." to try to get
the second method to run, but I keep getting argument errors.

I tried changing the "Private Sub" to "Public Sub" on the
header for the method I want to run, but that did not do
any good.

Thanks for your assistance in advance.

ps: In case it's not obvious, I'm a neophyte, a high school
teacher trying to keep my mind alive.

--jade
(e-mail address removed)
 
Hi jade,
There are a few ways you could do this. I'll present one of them.

I assume you already know how to open the form and I'm also going to
assume you're using 'DoCmd.OpenForm' to do it.

So, put this string in the OpenArgs argument of the OpenForm method so that
you have something like this:

DoCmd.OpenForm "yourForm",,,,,,"runCode"

Now, in the Open event of the second form put this:

If Me.OpenArgs = "runCode" Then
cmdNew_Record_click
End If

That's it. When you open your form from the button click in form 1, the code in your cmdNew_Record
routine will run.
 
Back
Top