Count number of changes

  • Thread starter Thread starter Josué
  • Start date Start date
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
 
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).
 
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.
 
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
 

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

Back
Top