Form / Subform issue

G

Guest

I have a form with a subform. I have run into an issue where I frequently
get an errror message when I try to "Clean Up" the Table that is the
RecordSource of the SubForm. By "Clean Up" I mean that I have a DoCmd.RunSQL
"DELETE ....." deleting some of the records WHERE certain condition(s)
exists. The problem is that sometimes in the "Clean Up" process it will give
me an error message saying that "Cannot perform procedure. One or more of
the records in the underlying table is being edited." I think is is because
Subform/Field2 has code on the OnExit event and if a user clicks from the
MainForm to Subform/Field2 and then clicks back to the main form it hangs up
the record in an edit mode. Does that sound like it might be the situation?
It seems to run ok if the user clicks on Subform/Field2 and then goes to
Subform/Field3 and then back to the MainForm. How do I handle this so if the
MainForm has the focus and then the user clicks directly to Subform/Field2
and then immediately back to the MainForm it will not error in the "Clean Up"
process. But, I really want to keep the code on the OnExit event of
Subform/Field2.

Thank you for your help,

Steven
 
S

strive4peace

Hi Steven,

save the record...

'in code behind form
if me.dirty then me.dirty = false

'in code behind parent form
if me.subform_controlname.form.dirty then
me.subform_controlname.form.dirty = false
end if

another source for the problem could be combos or listboxes that get
their criteria from form controls. I like to replace the SQL for the
rowSource everywhere control criteria is required so that the SQL has
hard-coded criteria. If this is an issue in your database, we can help
you with the code to do this if you tell us what the current
RowSource(s) SQL is...



Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

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