OnDirty Not Firing

P

PeterM

I have a form in AC2003. On that form there is a text control for a person's
weight. I have two small buttons just to the right of the text control. One
is an up button and the other is a down button. For the up button:

Private Sub cmdUpCbo_Click()
Me.GM_Weight = Me.GM_Weight + 1
End Sub

and for the down button:

Private Sub cmdDownCbo_Click()
Me.GM_Weight = Me.GM_Weight - 1
End Sub

The following is the code for the dirty event:

Private Sub Form_Dirty(Cancel As Integer)
Me.btnUndo.Enabled = True
Me.btnNew.Enabled = False
Me.btnSave.Enabled = True
Me.btnDelete.Enabled = False
TurnNavigationButtonsOff
End Sub

The problem is that if I go to the weight control and change the value
directly, the onDirty event fires, however, if I touch either the up or down
button, the value in the weight control does what I expect but the onDirty
event does not fire.

To debug this I set the RecordSelectors to Yes and ran the exact same test
with the same exact code. The record selector changes to the pencil if I
change the weight control directly or if I use the up or down buttons.

Why doesn't the onDirty event fire when I use the buttons?

Thanks for your help!
 
J

John W. Vinson

Why doesn't the onDirty event fire when I use the buttons?

By design. It only fires if the value changes because the user types or
selects something in a control.

Try explicitly setting Me.Dirty = True in your click event code.
 
P

PeterM

Understood...thank John.

John W. Vinson said:
By design. It only fires if the value changes because the user types or
selects something in a control.

Try explicitly setting Me.Dirty = True in your click event code.
 
D

David W. Fenton

Try explicitly setting Me.Dirty = True in your click event code.

Well, you learn something every day.

I wonder what doing that does to a record's generation number in a
replicated database...
 
A

a a r o n . k e m p f

I'd assume it would crash and burn any jet database, voiding the
transaction, and requiring re-entry of data
 

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