Count number of changes

J

Josué

Hi, i have searched the forum for one answer but haven't found it so here's
my question.
Is it possible to count the number of times that a date field in a form is
changed? how do I do it?
TIA
 
W

Wayne-I-M

Hi

One idea - create a new table (tblChanges) link this to the table you want
to count the changes on and then use the after update event in the form to
add one (maybe Dmax...+1, etc or just use a query with an if.... (default =
0).
 
B

Brendan Reynolds

Josué said:
Hi, i have searched the forum for one answer but haven't found it so
here's
my question.
Is it possible to count the number of times that a date field in a form is
changed? how do I do it?
TIA


Do you want to record only a single total, the number of times the field was
changed for any and all records, or do you want to record separately the
number of times the field was changed for each record?

To record only a single total, you could do something like this ...

Private Sub txtTest_AfterUpdate()

Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT TestNum FROM tblTest")
With rst
If (.BOF And .EOF) Then
.AddNew
Else
.Edit
End If
.Fields("TestNum") = Nz(.Fields("TestNum"), 0) + 1
.Update
.Close
End With

End Sub


.... where "txtTest" is the name of the textbox, "TestNum" is the name of the
field in which you want to record the total, and "tblTest" is the name of
the table containing that field.
 
S

Steve Schapel

Josué

I think you would need to have another field in the table (and also
shown on the form) especially for this purpose. And on the AfterUpdate
event of the date field, code something like this:
Me.NameOfCounterField = Me.NameOfCounterField + 1
 
Top