From: alex on
When does record become dirty?

Hello,

I posted a question about the dirty property in the immediate window…I
think this question is different, so that’s why I’m posting it here.

In the On Dirty event of all my text/combo boxes I call this function
(=IsRecordDirty()):

Private Function IsRecordDirty()
Debug.Print Me.Dirty
If Me.Dirty Then
Me.cmdUndo.Enabled = True
Me.cmdSave.Enabled = True
Else
Me.cmdUndo.Enabled = False
Me.cmdSave.Enabled = False
End If
End Function

When I open the form, click on a textbox, and type data, the On Dirty
event of that control fires, but fires Me.Dirty = False.

I then click a second textbox, type data, the On Dirty event of that
control fires Me.Dirty = True.

This happens every single time…I don’t understand why the record does
not become dirty until I (1) click a control and type data, (2) click
a second control and type data (now causing the record to dirty).

Any help as to what I’m doing wrong would be appreciated!
Thanks,
alex
From: Dirk Goldgar on
The form's Dirty property becomes True when a modification to a bound
control is actually committed -- stored in the bound field of the form's
recordset. If you modify a control's value, that modification is not
committed until you leave the control, leave the record, or close the form.
Editing a bound control fires the control's Dirty *event* (and the form's
Dirty event), but the record doesn't actually become dirty until you move on
to the next control, or otherwise do something to commit the edit.

I don't understand why you are using the Dirty events of all your text/combo
boxes, rather than just using the Dirty event of the form itself. Wouldn't
that be simpler?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)


"alex" <sql_aid(a)yahoo.com> wrote in message
news:a7d35723-8b93-4193-b3de-a1697ddc4fbd(a)q16g2000yqq.googlegroups.com...
When does record become dirty?

Hello,

I posted a question about the dirty property in the immediate window�I
think this question is different, so that�s why I�m posting it here.

In the On Dirty event of all my text/combo boxes I call this function
(=IsRecordDirty()):

Private Function IsRecordDirty()
Debug.Print Me.Dirty
If Me.Dirty Then
Me.cmdUndo.Enabled = True
Me.cmdSave.Enabled = True
Else
Me.cmdUndo.Enabled = False
Me.cmdSave.Enabled = False
End If
End Function

When I open the form, click on a textbox, and type data, the On Dirty
event of that control fires, but fires Me.Dirty = False.

I then click a second textbox, type data, the On Dirty event of that
control fires Me.Dirty = True.

This happens every single time�I don�t understand why the record does
not become dirty until I (1) click a control and type data, (2) click
a second control and type data (now causing the record to dirty).

Any help as to what I�m doing wrong would be appreciated!
Thanks,
alex


From: alex on
On Feb 25, 2:25 pm, "Dirk Goldgar"
<d...(a)NOdataSPAMgnostics.com.invalid> wrote:
> The form's Dirty property becomes True when a modification to a bound
> control is actually committed -- stored in the bound field of the form's
> recordset.  If you modify a control's value, that modification is not
> committed until you leave the control, leave the record, or close the form.
> Editing a bound control fires the control's Dirty *event* (and the form's
> Dirty event), but the record doesn't actually become dirty until you move on
> to the next control, or otherwise do something to commit the edit.
>
> I don't understand why you are using the Dirty events of all your text/combo
> boxes, rather than just using the Dirty event of the form itself.  Wouldn't
> that be simpler?
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips:www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>
> "alex" <sql_...(a)yahoo.com> wrote in message
>
> news:a7d35723-8b93-4193-b3de-a1697ddc4fbd(a)q16g2000yqq.googlegroups.com...
> When does record become dirty?
>
> Hello,
>
> I posted a question about the dirty property in the immediate window I
> think this question is different, so that s why I m posting it here.
>
> In the On Dirty event of all my text/combo boxes I call this function
> (=IsRecordDirty()):
>
> Private Function IsRecordDirty()
> Debug.Print Me.Dirty
> If Me.Dirty Then
>     Me.cmdUndo.Enabled = True
>     Me.cmdSave.Enabled = True
> Else
>     Me.cmdUndo.Enabled = False
>     Me.cmdSave.Enabled = False
> End If
> End Function
>
> When I open the form, click on a textbox, and type data, the On Dirty
> event of that control fires, but fires Me.Dirty = False.
>
> I then click a second textbox, type data, the On Dirty event of that
> control fires Me.Dirty = True.
>
> This happens every single time I don t understand why the record does
> not become dirty until I (1) click a control and type data, (2) click
> a second control and type data (now causing the record to dirty).
>
> Any help as to what I m doing wrong would be appreciated!
> Thanks,
> alex

Dirk,

Thanks for responding; I appreciate it.

Yes, it would probably be easier to use the form’s Dirty Event, but I
can’t get it to fire (or fire true).

What I’m trying to do is enable a Save and Undo button when the record
becomes dirty. I know the record is automatically saved when the next
record is displayed, but I’d like to give the user an option to hit
the Save button or highlight the Undo button when it can actually undo
something!

How can I use the Form’s On Dirty event to test whether the form is
actually dirty (after a control receives a new value and before the
commitment you mentioned)?

Thanks,
alex
From: Dirk Goldgar on
"alex" <sql_aid(a)yahoo.com> wrote in message
news:2e9ee3f6-c492-418b-8d97-4291391c2503(a)v25g2000yqk.googlegroups.com...
> Yes, it would probably be easier to use the form�s Dirty Event, but I can�t
> get it to fire (or fire true).
>
> What I�m trying to do is enable a Save and Undo button when the record
> becomes dirty. I know the record is automatically saved when the next
> record is displayed, but I�d like to give the user an option to hit the
> Save button or highlight the Undo button when it can actually undo
> something!
>
> How can I use the Form�s On Dirty event to test whether the form is
> actually dirty (after a control receives a new value and before the
> commitment you mentioned)?

Why do you need to test whether the form is dirty in the Dirty event? If
the Dirty event fires, then some bound control has been changed. For your
purposes, it doesn't matter whether the modified control value has been
committed or not -- it *will* be, unless the user "undoes it". Therefore,
all you need to do in the Dirty event is enable your Undo and Save buttons:

Private Sub Form_Dirty()

Me.cmdUndo.Enabled = True
Me.cmdSave.Enabled = True

End Sub

Of course, you will want to disable those buttons in the form's Current
event and its AfterUpdate event:

Private Sub Form_AfterUpdate()

Me.cmdUndo.Enabled = False
Me.cmdSave.Enabled = False

End Sub

Private Sub Form_Current()

Me.cmdUndo.Enabled = False
Me.cmdSave.Enabled = False

End Sub

Maybe I'm missing something, but I don't see what else you might need to do.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

From: alex on
On Feb 25, 4:17 pm, "Dirk Goldgar"
<d...(a)NOdataSPAMgnostics.com.invalid> wrote:
> "alex" <sql_...(a)yahoo.com> wrote in message
>
> news:2e9ee3f6-c492-418b-8d97-4291391c2503(a)v25g2000yqk.googlegroups.com...
>
> > Yes, it would probably be easier to use the form s Dirty Event, but I can t
> > get it to fire (or fire true).
>
> > What I m trying to do is enable a Save and Undo button when the record
> > becomes dirty.  I know the record is automatically saved when the next
> > record is displayed, but I d like to give the user an option to hit the
> > Save button or highlight the Undo button when it can actually undo
> > something!
>
> > How can I use the Form s On Dirty event to test whether the form is
> > actually dirty (after a control receives a new value and before the
> > commitment you mentioned)?
>
> Why do you need to test whether the form is dirty in the Dirty event?  If
> the Dirty event fires, then some bound control has been changed.  For your
> purposes, it doesn't matter whether the modified control value has been
> committed or not -- it *will* be, unless the user "undoes it".  Therefore,
> all you need to do in the Dirty event is enable your Undo and Save buttons:
>
>     Private Sub Form_Dirty()
>
>         Me.cmdUndo.Enabled = True
>         Me.cmdSave.Enabled = True
>
>     End Sub
>
> Of course, you will want to disable those buttons in the form's Current
> event and its AfterUpdate event:
>
>     Private Sub Form_AfterUpdate()
>
>         Me.cmdUndo.Enabled = False
>         Me.cmdSave.Enabled = False
>
>     End Sub
>
>     Private Sub Form_Current()
>
>         Me.cmdUndo.Enabled = False
>         Me.cmdSave.Enabled = False
>
>     End Sub
>
> Maybe I'm missing something, but I don't see what else you might need to do.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips:www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)

Dirk,

I must not understand the Dirty Property...

I place this code in my form module and it never fires...ever:

Private Sub Form_Dirty(Cancel As Integer)

Me.cmdUndo.Enabled = True
Me.cmdSave.Enabled = True
MsgBox "form_dirty fired"

End Sub

I'm guessing that if I change the value of my controls the dirty event
should fire. I must have code somewhere that is saving the form
automatically thereby not allowing the form's dirty event to fire...

I think we're on the same page. As a side note: What can I do to the
form that in your opinion would cause the form's dirty event to fire?

Thanks,
alex