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

Passing multiple arguments to OpenArgs 3

Status
Not open for further replies.

dynamictiger

Technical User
Dec 14, 2001
206
AU
I am fiddling around with an app, that would benefit from passing multiple open args from one form to another.

How is this done and how is it seperated when you open the target form?
 
Could be done various ways. If you don't close the first form, you can just refer to its fields from the target form. If you're using the first form's fields to determine a filter in the target form, you can put them in the OpenForm command's 'where' argument.

If you're wanting to carry the information and close the first form, the second form needs either fields (invisible) or variables that refer the args you want to pass. In the form's Open event, you can refer to the first form's fields to copy them into the target form's fields/variables.
 
I gave the above alternatives because I've never used OpenArgs. I know that function calls usually allow multiple values in an argument using '|'. I don't know, however, how you would distinguish them when reading the OpenArgs argument or if it even allows multiple values.

One way around it, however, would be to concatenate the values into one string using a delimiter. For example,

strOpenArgs = str1 & ";" & str2 & ";" & ...

You can then use string functions such as InStr, Left, and Mid, to separate the string into various arguments. For example,

strOpenArgs
str1 = Left(strOpenArgs, InStr(1,strOpenArgs,";")-1)
strOpenArgs = Mid(strOpenArgs, InStr(1,strOpenArgs,";")+1)
str2 = Left(strOpenArgs, InStr(1,strOpenArgs,";")-1)
strOpenArgs = Mid(strOpenArgs, InStr(1,strOpenArgs,";")+1)
...

Here's another alternative.
 
Thanks the second post is what I am trying to do. I haven't used OpenArgs before much either.
 
if you are using A2k then you can make use of the split function. This takes a delimited list, and the seperator and turns it into an array.

if openargs is 1;2;3;4;5;6

Dim sArgs() as Variant
sArgs=split(openargs,";")

you can then use
sArgs(0) to get the first argument
sArgs(1) to get the second and so on.

I have seen some custom functions written for A97 that do the same thing, though I have never used one myself.

HTH

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top