Detect If Subform Is Dirty From Main Form

G

Guest

Access 2003/WinXP

How do I detect whether a subform is Dirty from the main form?

I've tried the following:

Forms("subformname").Dirty --> Error: Access cannot find the form
"Subformname"

Me.subformname.Dirty ---> Error: Object does not support this property or
method

Me!subformname.Dirty ---> Error: Object does not support this property or
method

Me.subformcontrolname.Form.Dirty ---> Error: Object does not support this
property or method

Help!
 
D

Daniel Doyle

I'm not sure how you can do this as when you move from the subform to the
main form, the subform will refresh and will no longer be dirty. Maybe
someone can correct me, but I don't think that it's possible for a subform
to be dirty when you are in the main form.
If this is right, you may need to check the Dirty property from the subform,
or write some custom code.
Is there a reason why you can't check the subform's Dirty property from
within the subform?

Dan.
 
G

Guest

This code is going to go under the "Close" event of the main form. I'm trying
to make sure that my users don't close the form with any unsaved changes.
 
D

Daniel Doyle

Are your forms bound to tables in the database? If so, records will save
when you move to another record, leave the subform or close the main form.
If the record cannot be saved, Access will display an error message.

Dan.
 

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