Somehow Openargs became Null

M

mscertified

I was testing my app and it errored out and it turned out the value of
Openargs was Null.
I set Openargs to either a record key (if modifying a record) or zero (if
adding a record) in the calling form. Nowhere do I set it to null. How could
Openargs have become Null? I believe it is a read-only value so what would
cause this?

Thanks.
 
D

Dirk Goldgar

mscertified said:
I was testing my app and it errored out and it turned out the value of
Openargs was Null.
I set Openargs to either a record key (if modifying a record) or zero (if
adding a record) in the calling form. Nowhere do I set it to null. How
could
Openargs have become Null? I believe it is a read-only value so what would
cause this?


Did you perhaps flip your form into design view and back while you were
testing it?
 
M

mscertified

No, I'm just running in normal mode then when the error occurs I view the
value in the immediate window. Right now, I'm trying to narrow down where
exactly it becomes null.
 
M

mscertified

OK, I now know where it is happening. At the end of my butSave_Click
procedure is a Docmd.Close. This is triggering the BeforeUpdate event because
I have changed a bound field. Before the Docmd.Close, Openargs is still zero.
At the top of BeforeUpdate it has become Null. Any ideas?
 
D

Dirk Goldgar

mscertified said:
OK, I now know where it is happening. At the end of my butSave_Click
procedure is a Docmd.Close. This is triggering the BeforeUpdate event
because
I have changed a bound field. Before the Docmd.Close, Openargs is still
zero.
At the top of BeforeUpdate it has become Null. Any ideas?


You told it to close, so Access feels justified in discarding the value of
OpenArgs. I suggest that in your butSave_Click procedure you force the
record to be saved before calling DoCmd.Close. Something like:

If Me.Dirty Then Me.Dirty = False
DoCmd.Close acForm, Me.Name, acSaveNo
 

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

Top