Reputation: 590
I'm wanting to run a procedure from a form that was open via openargs
This is how I am opening the form.
DoCmd.OpenForm "Loading_Form", acNormal, , , , acWindowNormal, DynaProgBarMax & "|" & DynaLableCaption & "|" & ProcCall & "|"
This is what is ran when the form opens.
Private Sub Form_Open(Cancel As Integer)
Dim OpenArgsAry As Variant
OpenArgsAry = Split(Me.OpenArgs, "|")
Me.DynaProgBar.Max = OpenArgsAry(0)
Me.DynaLable.Caption = OpenArgsAry(1)
Run OpenArgsAry(2)
End Sub
I am having an issue with Run OpenArgsAry(2)
. I'm getting an error stating that the Procedure can not be found. OpenArgsAry(2)
is containing a string "Forms(""Stuff"").PrintAllStuff()"
. When I Replace Run OpenArgsAry(2)
with Run Forms("Stuff").PrintAllStuff()
it works fine.
Run
is suppose to be able to run a string as the procedure name is it not?
Upvotes: 2
Views: 106
Reputation: 32642
Run
requires a procedure (sub or function in a global module, not a form or class module). PrintAllStuff
is a method on a form, thus can't be executed through Run
.
However, you can execute it through CallByName
:
CallByName Forms("Stuff"), OpenArgsAry(2), vbMethod
Where OpenArgsAry(2)
only contains PrintAllStuff
. You can use Me
instead if you want to execute the method on the current form.
Upvotes: 1