OpenArgs losing value

  • Thread starter Thread starter Alvin
  • Start date Start date
A

Alvin

formA calls formB using the DoCmd.OpenForm method and
passes values using OpenArgs.

But under some conditions, formB.OpenArgs will be NULL and
I can't figure out why. It works some times but not others.

I can debug the code, and watch the DoCmds in formA get
built and I can verify that I am passing a non-null value,
but when formB loads, it is now Null!!

If I close Access (2002 on Windows 2000) and restart, this
generally fixes the problem, but not always.

Has anyone else run into this? Any suggestions for a fix?

TIA.
 
Sounds like you are getting an error - which will destroy local and global
variables, but error trapping is turned off, so you dont see the error
causing the problem.


--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
If formB is already open (even if not visible), the OpenForm method does not
reinitialize it, so it retains the state of its OpenArgs when it was
originally opened.
 
To piggyback on this, my approach to avoiding this error-loss problem is to
put an invisible textbox on the form (call it txtOpenArgsValue), and in the
form's OnOpen event, I store the value of the OpenArgs argument into this
textbox right away. Then I can reference it at any point while the form is
open, even if an error occurs.
 
Back
Top