No Current Record on form close

G

Guest

I think I know what's causing this but not how to fix it.

I have a subform tied to my main form and when I close the main form when
the subform has no records, I get a "No Current Record" error (no error
number, just the text).

When I close my form and the subform has associated records, everything is
fine.

How can I bypass or prevent this dialog box from appearing when I close a
main form with no related records in the subform?

Thanks!
 
R

ruralguy via AccessMonster.com

When you close a form with a SubForm, the MainForm closes 1st and then the
SubForm will close. Do you have some code in the OnClose or Unload event of
the SubForm?
 
G

Guest

No code on the subform for OnClose or Unload (I had none yesterday, and today
moved it to a tab so now there isn't any OnClose or Unload events for the
subform itself.

The tabs have a MouseMove code, and the main form has OnCurrent and
OnGotFocus events.

The OnCurrent code sets up a recordset clone to check for the total number
of records in the subform to modify the status of some buttons and text
fields.

The OnGotFocus code just requeries the main form.

Do you think any of that would cause this problem? You said that the main
form unloads, then the subform...can I somehow put code in the OnClose event
of the main form that closes the subform first? (I'm not 100% positive of the
event processing order when forms close)
 
R

ruralguy via AccessMonster.com

You really do not want to change the sequence of events. As a diagnostic,
just comment out code until the error goes away to locate the problem code.
Once located, there will almost certainly be a better solution.

Robert_L_Ross said:
No code on the subform for OnClose or Unload (I had none yesterday, and today
moved it to a tab so now there isn't any OnClose or Unload events for the
subform itself.

The tabs have a MouseMove code, and the main form has OnCurrent and
OnGotFocus events.

The OnCurrent code sets up a recordset clone to check for the total number
of records in the subform to modify the status of some buttons and text
fields.

The OnGotFocus code just requeries the main form.

Do you think any of that would cause this problem? You said that the main
form unloads, then the subform...can I somehow put code in the OnClose event
of the main form that closes the subform first? (I'm not 100% positive of the
event processing order when forms close)
When you close a form with a SubForm, the MainForm closes 1st and then the
SubForm will close. Do you have some code in the OnClose or Unload event of
[quoted text clipped - 13 lines]
 

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