OpenArgs losing value

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.
 
A

Adrian Jansen

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
 
A

Allen Browne

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.
 
K

Ken Snell

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top