Why does this variable lose its value?

tvanstiphout

Well-known member
Local time
Yesterday, 18:36
Joined
Jan 22, 2016
Messages
650
Access splitforms have their issues, so I wanted to write my own lookalike.
Open mySplitForm, and observe you can navigate using the mainform, or the unbound listbox. To make this a generic module I am using form subclassing. So far so good.
Now filter the mainform. You will get an error because m_fldPK has lost its value. Why is that?
The subclass' Terminate method has not been called. There is no code to set this variable to Nothing. The Form_Open event is not called again to create a new instance of the subclass.
Maybe this is an Access bug?
 

Attachments

Could it be you have an un-trapped error causing the global m_SplitForm in mySplitForm to be cleared?
 
Never mind, I figured it out: the Field object is a reference to a field in the form's RecordsetClone. Filtering the form changes the RecordsetClone and thus the field is no longer valid.
I changed the code to use the field name (as a string) instead, and that works.
 

Users who are viewing this thread

Back
Top Bottom