Data input forms, "Exit w/o saving?"

R

robert.waters

I have several unbound data input forms, and in each I have a boolean
flag variable to indicate whether or not the user has saved their
input. When the form closes, I check this variable; if it is false, I
ask the user if they're sure that they want to continue closing and
lose the data.
The unfortunate consequence of this method is that if you open the
form and then close it right away (without entering any data), you are
asked that (at this time pretty irrelevant) question.
Does anyone know what method I could use, besides checking the value
of each of the input controls or setting a flag in the OnEnter or
OnChange event of each input control, to determine if the form is
'Dirty'?

I guess the short version of this question is "How might I implement a
'Dirty' property for an unbound form?"

Thanks!
 
D

Douglas J. Steele

Robert said "unbound data input forms": Dirty only applies to bound forms.

Robert: What I sometimes do is put code in the AfterUpdate event of each
control that sets a flag indicating something has changed, but that's not
much better than what you're trying to avoid.
 
S

SusanV

Didn't know that - thanks Doug!

Douglas J. Steele said:
Robert said "unbound data input forms": Dirty only applies to bound forms.

Robert: What I sometimes do is put code in the AfterUpdate event of each
control that sets a flag indicating something has changed, but that's not
much better than what you're trying to avoid.
 
B

BruceM

Maybe you could have the form open with the focus on a control; then, in the
exit event for the control, reset the flag if the control contains a value.
The control would probably have to be required, and validated in the command
button's click event, or something like that.
Or just use the timer event to reset the flag after the form has been open
for fifteen seconds or whatever.
None of this is thought through very carefully. Just tossing some ideas
into the mix.
 

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