Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with tabs and Me.Dirty

Status
Not open for further replies.

planetdrouin

Technical User
Dec 29, 2001
36
US
I have a form which has a tab control with 5 pages. On one of the pages is a subform. I am attempting to add Me.Dirty then Me.Undo logic to an exit button. Is this possible with tab pages and especially with a subform on one of them?

Thanks

Lawrence
 
Maybe, but if you're trying to check the subform and the main form, I'd say it's a long shot. I almost never use the Me.Dirty property because it's so arbitrary; even a change in an unbound control made through code will result in .Dirty being True, which seems pretty silly to me.

I get around it by using a hidden check box called ckDirty, whose default value is False. Then a single after-update function which you can add to all relevant controls, which "checks" that box. You can do the same thing on the subform by using Me.Parent!ckDirty = True. Then you check that value before exiting/changing records, and if it's true you "keep" the record or whatever, if it's false you undo. Much finer control, and not too much code, either. Don't forget to reset ckDirty to false in the OnCurrent event or whatever.
 
I don't think the dirty property is arbitrary, exactly, but it often won't work the way you want it to.

For example, me.dirty on a tabbed form will be true if any control on the entire form is changed (I think), regardless of which tab it's on. So you can't undo just the changes on a single tab.

I think you could use a cancel button on a main form to check the dirty property on a subform and process it in the main form's module. You will have to use full references and not merely the 'Me.Dirty' reference, when doing it this way. Also, if the subform is a multi-record one (using a one-to-many relationship with main table) you can't undo changes on a subform once a user has moved to a new record on the subform.

There are ways to put all the changes on a form and even its multirecord subforms into a transaction that is committed or rolled back depending on whether user clicks "OK" or "Cancel", but that's more complicated. -- Herb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top