Openargs and how to

  • Thread starter Thread starter DubboPete
  • Start date Start date
D

DubboPete

I know that OpenArgs is probably the thing I need to learn, but what I
am trying to do is capture a client code from one screen, close that
screen, and open another and paste the client code into a client code
field...

Is this the best way? Or can someone suggest another [better] bit of
code to do it?

tia
Dubbopete
 
You can use OpenArgs method (note that the OpenArgs value will be a text
string when it gets to the second form):


Code in first form that opens the second form:
DoCmd.OpenForm "SecondFormName", OpenArgs:=Me.ClientCodeControl.Value

Code in OnLoad event of second form:
Me.ClientCodeControl.Value = Me.OpenArgs
 
Many thanks Ken, that's just the answer I was looking for!

Pete

Ken Snell said:
You can use OpenArgs method (note that the OpenArgs value will be a text
string when it gets to the second form):


Code in first form that opens the second form:
DoCmd.OpenForm "SecondFormName", OpenArgs:=Me.ClientCodeControl.Value

Code in OnLoad event of second form:
Me.ClientCodeControl.Value = Me.OpenArgs


--
Ken Snell
<MS ACCESS MVP>


DubboPete said:
I know that OpenArgs is probably the thing I need to learn, but what I
am trying to do is capture a client code from one screen, close that
screen, and open another and paste the client code into a client code
field...

Is this the best way? Or can someone suggest another [better] bit of
code to do it?

tia
Dubbopete
 
Dirk Goldgar said:
I believe it's a Variant(String), so it's either Null or a String value.


Ok, that sounds right.

I checked some old code last night, & found a comment saying that openargs
is Null in each of three cases:
- user did not supply a value on the openform;
- user supplied a null;
- user supplied a zero-length string!

So, according to that old comment, the called form can not distinguish those
three cases! (unless, of course, it used magic values eg. chr$(1) = assume
no value was supplied, chr$(2) = assume a ZLS was supplied, etc.)

For interest, is that how it works for you?

Cheers,
TC
 
Sorry...Dirk is correct that it's a variant with string.

You also get Null in OpenArgs if an unhandled error occurs in the
code...OpenArgs will be reset to default value (Null) in that case, just as
"global" variables can be reset.

I've never tried to test for OpenArgs as a zero-length string. I always test
whether it's empty by using
If Len(Me.OpenArgs & "") = 0 Then

So your old code's notes may be correct.
 
TC said:
Ok, that sounds right.

I checked some old code last night, & found a comment saying that
openargs is Null in each of three cases:
- user did not supply a value on the openform;
- user supplied a null;
- user supplied a zero-length string!

So, according to that old comment, the called form can not
distinguish those three cases! (unless, of course, it used magic
values eg. chr$(1) = assume no value was supplied, chr$(2) = assume a
ZLS was supplied, etc.)

For interest, is that how it works for you?

I just tested it in Access 2002, and the comment seems to be correct.
That last item surprised me.
 
Dirk Goldgar said:
I just tested it in Access 2002, and the comment seems to be correct.
That last item surprised me.


Me too! I'd prefer Empty if not supplied, Null if null, and anyhting else
verbatim (including zls).

Such is life ...

Cheers,
TC
 
Back
Top