Passing an array parameter to forms Open Event

  • Thread starter Thread starter Arvi Laanemets
  • Start date Start date
A

Arvi Laanemets

Hi

When opening a form using DoCmd.Openform method, the last parameter can be
used to pass a parameter to form's Open event. My question is, can this
parameter be an array? I need to send 3 different values (a string, an
integer and a date) to form. Of course I can create a text string formatted
accordingly and then in forms Open event initialize 3 different variables
from it, but is there an easier way. (My application must be compatible with
Access2000.)
I searched and did find out, that for functions/procedures is it possible to
pass an array as parameter. What about Form and it's OpenArgs property?


Thanks in advance!
Arvi Laanemets
 
OpenArgs is a string, but you can use a separator, like a comma, and parse
out that string and covert convert each element to anything that will work.
 
OpenArgs is a string, but you can use a separator, like a comma,
and parse out that string and covert convert each element to
anything that will work.

And, of course, you can use Join() to convert data stored in an
array into a string for passing as an OpenArg, and then use Split()
to reconstitute it in the receiving form.

I wouldn't actually ever *do* that, but it's possible.

And, of course, it's limited to a 1 dimensional array.
 
David W. Fenton said:
And, of course, you can use Join() to convert data stored in an
array into a string for passing as an OpenArg, and then use Split()
to reconstitute it in the receiving form.

Yes that's one way to parse.
I wouldn't actually ever *do* that, but it's possible.

I've never had a need to do it, but I see nothing wrong with the technique.
 
Yes that's one way to parse.


I've never had a need to do it, but I see nothing wrong with the
technique.

I believe that using OpenArgs to pass more than one piece of
information to a form indicates a design error. It's better to use a
data structure independent of the calling and called forms, because
otherwise, the dependencies can be extremely difficult to
troubleshoot. I would tend to use a standalone class module.
 
Hi

I did find out about this soon after I posted my question here. Googling for
'openargs' did the trick.


Arvi Laanemets.
 
I have a special case here. I need to call same popup form from a couple of
other forms to make some operations (editing, adding or deleting) on several
records of certain table at one go (the table connects employees with
operations on objects at some time moment). And it depends on calling form,
which set of records it is - so I use OpenArgs to initialize the popup form.


Arvi Laanemets
 
Back
Top