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

OpenArgs

Status
Not open for further replies.

citychap26

Programmer
Sep 19, 2004
144
0
0
GB
Hi Chaps,

Just wondered, is OpenArgs the best way to pass information between forms?

Cheers

S
 
Hi

OpenArgs is a one-way pass, unless you start opening and closing forms which could get a bit messy.

You can still access values on one form from another, but you have to be aware of the pit-falls of referencing a closed form, for instance.

Passing data by OpenArgs is ok if you have limited info to pass and you can even pass a delimited string to represent more than one piece of information, but the form receiving has to parse the OpenArgs to break the string down e.g.

Passing "True,12346, View" as an OpenArg could represent 3 pieces of information to be used by the receiving form, but the receiving form would have to know how to handle the string etc

Hope this helps
 
citychap26 said:
[blue]Just wondered, is OpenArgs the best way to pass information between forms?[/blue]
There's no such thing as the best here. [blue]Its what fits, works well, and how you make use of things that makes the difference[/blue] in your design.

Now . . . when using [purple]OpenArgs[/purple], the thing to remember is that it only accepts a string. So if you intend to pass numeric you'll have to perform two conversions. Numeric to String in [purple]OpenArgs[/purple]:
Code:
[blue]docmd.OpenForm "FormName", , , , , Str(Numeric Value)[/blue]
Then back to numeric in the opened form:
Code:
[blue]Me!TextBox1 = Val(Me.[purple]OpenArgs[/purple])[/blue]
Also, [purple]OpenArgs[/purple] is not limited to a single string value. Just via the string you could send a delimited list of values, then break it down in the opened form:
Code:
[blue]docmd.OpenForm "FormName", , , , , "Now,Is,The,Time"[/blue]
Or
Code:
[blue]docmd.OpenForm "FormName", , , , , Me!TextBox1 & "," & Me!TextBox2 & "," & Me!TextBox3[/blue]
As an Idea of the use of [purple]OpenArgs[/purple], consider you have a form that can be opened by anyone of several others, and you take action in the opened form depending on the calling form. [blue]You would pass the form name[/blue] using [purple]OpenArgs[/purple].

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top