Nhan said:
but that was only additional inform. The main problem is, Dirty event
is not fired in reaction on user action
To demonstrate my case.
Following is a modul, Form Tabelle1 is bound to any table, this Form
had Form_Dirty procedure, which prints only a line "dirty".
when sub test runs, the line "dirty" is always printed out.
'**********
'Modul1
Option Compare Database
Option Explicit
Dim frm As Form_Tabelle1
Public Sub test()
Set frm = New Form_Tabelle1
frm.Visible = True
frm.test.Value = "jdjdjdj"
End Sub
'******
'form Tabelle1
Option Compare Database
Option Explicit
Private Sub Form_Dirty(Cancel As Integer)
Debug.Print "dirty"
End Sub
Up to now I thought you were saying that the Dirty event was not firing
when it should. Now you seem to be saying that it *is* firing when it
shouldn't. Regardless, it doesn't behave that way for me. I created a
new form named "TestDirty", bound to table "My Table" with bound field
"My Field", and I gave it this code module:
'------ start of form's code module ------
Option Compare Database
Option Explicit
Private Sub Form_Dirty(Cancel As Integer)
Debug.Print "Dirty"
End Sub
'------ end of form's code module ------
Then I created the following procedure in a standard module:
'------ start of test procedure code ------
Sub TestDirty()
Dim frm As Form_TestDirty
Set frm = New Form_TestDirty
frm.Visible = True
frm.[My Field].Value = "jdjdjdj"
Stop
frm.Undo
End Sub
'------ end of test procedure code ------
When I ran the test procedure, the line "Dirty" was not printed in the
Immediate window, neither before nor after the breakpoint.
Then I modified the test procedure like this:
'------ start of test procedure code ------
Sub TestDirty()
Dim frm As Form_TestDirty
Set frm = New Form_TestDirty
frm.Visible = True
frm.[My Field].SetFocus
frm.[My Field].Text = "jdjdjdj"
Stop
frm.Undo
End Sub
'------ end of test procedure code ------
When I ran this modified procedure, the line "Dirty" was printed in the
Immediate window before the breakpoint was reached.
So I am seeing behavior that matches what I would expect, and that
doesn't match what you report. Are you sure your test form has no other
code in it?
Have we established what version of Access you're using? I'm testing
with Access 2002, and could test if necessary with Access 97 and 2000,
but if you're using Access 2003, I can't check your results in that
version.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)