Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make OpenArgs Passed Data Conditional?

Status
Not open for further replies.

tgikristi

Technical User
Jul 31, 2002
39
US
When opening a form using DoCmd I am using the OpenArgs statement already to pass data from multiple controls, but I don't want the opened form to refer to the openargs statement unless that form has been opened from a certain other form (because it could stand alone under different circumstances).

So I tried to determine which form has called the form and to do that I found thread702-88008, but I do not know where to put the Private statement in the code of that thread...the code from that thread is:

"...
private frmCalledFrom as Form
public sub SetForm (Calling as Form)
set frmCalledFrom = Calling
end sub

Assuming your calling form uses a button to call, in the OnClick event, put this code (after the form has been opened): Forms![Form A].SetForm Me

Now, when you want to reference the calling form, you can do so by using the frmCalledFrom object. To get the name, you'd use: frmCalledFrom.Name"

If there is a better way to do this, I'd appreciate it...
Thanks!!
tgikristi
 
If the program is stand alone or has been called with no parms passed (such as from a menu program), then OpenArgs will be null. When I have forms that can be either called or stand alone, I put code like the following in the form open event:

If isnull(OpenArgs) Then 'Stand alone
some code
Else
other code
End If

If you need to differentiate your OpenArgs code depending on the calling program, just include it as one of the parms in OpenArgs something like this:

If isnull(OpenArgs) Then 'Stand alone
some code
Else
If instr(OpenArgs, "CallingProgram1") > 0 then
other code1
Else
other code2
End If
End If

Good Luck!
 
Thank you so much...sometimes I get too overwhelmed to see the simple solution!

*tgikristi*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top