Somehow Openargs became Null

  • Thread starter Thread starter mscertified
  • Start date Start date
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.
 
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?
 
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.
 
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?
 
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
 
Back
Top