Hi Stuart
Okay, the common factor here is that you are modifying the code while it is
running - in break mode, while the form is open (not in design view).
Without proof, I suspect that this is corrupting your project and causing
the crashes.
Access keeps 2 copies of the code: the text version (not present in an MDE),
and the compiled version which actually runs. When you modify an object such
as a form, Access creates a temporary copy (so you can revert to the last
saved version of the code). When you begin to modify a form by altering the
code in break mode while it is already open, there are now 4 copies that it
is supposed to keep correctly synchronized, and I believe that it sometimes
gets this wrong. The evidence is that there are times when you make a change
in break mode, but the Compile option on the Debug menu remains disabled,
i.e. Access does not recognise that the project needs recompiling.
We originally noticed this when working with subforms (where it is much more
convenient to change the code in break mode, rather than close the form,
open the subform and its module in design view, locate the line, and make
the changes). Once we twigged what was causing the corruption and stopped
editing in break mode, we found that corruptions in A97 dropped to about 1/4
of what it was previously.
Undoubtedly, your mdb now contains corruption that will not be fixed simply
by a decompile. After another decompile and compact, create a new (blank)
database, and import everything. If one particular form is problematic, you
may want to use the undocumented SaveAsText and LoadFromText rather than
import it directly from the corrupted database.
Regarding the code that passes the value of the control to a global, try:
Call MyFunc(Me.MyTextBox.Value)
so that Access passes just the Value rather than passing an object of type
TextBox.
For other suggestions, see:
Preventing Corruption
at:
http://members.iinet.net.au/~allenbrowne/ser-25.html
Issue #1 you've done.. #2 and #3 do not apply to A97. #5 is the main one.
You cannot prevent some corruptions while developing in A97, but it is
possible to reduce them to about once a week.
HTH