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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a variable when opening a form.

Status
Not open for further replies.

Dustman

Programmer
May 7, 2001
320
US
I've got a variable that I'm needing to pass to a form when I open it from another procedure. I can't use the OpenArgs because its for strings only.. is a global variable my only option? I don't want to make it global unless I absolutely have to.

The variable is a custom type with several different values, so I can't just send a string.
-Dustin
Rom 8:28
 
Where do you need to use the variable? I had the same problem because I needed to pass multiple variables in order to link forms - I needed to pass the field name, data type and the string to search for. The way I managed it was to add a public sub proc to the target form, with a variable of your custom type as the input parameter. Inside that sub-proc you can manipulate the data and the current form.
eg in the target form
Public Sub ReceiveVar(cusMyVar As CustomType)
...
End Sub

And in the initial form
Forms![TargetForm].ReceiveVar cusMyVar

And BTW that's an awfully pious reference to God's works.
 
You send a string delimited by a combination of characters which you never use - say |~ then use the Mid/Instr functions to extract the fields on opening the receiving form.
 
Dustin,

The correct way to do this is to add a property to the receiving form. This can then be called in the same way as any other property.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top