How do I count records entered in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to count how many times a button is pushed on an Access form. You see
the data that is entered is very repetative. Many of the records the only
thing that changes is the Primary Key Autonumber, beacuase I am entering in
50 or 60 of the same item. If I can have a couter for how many times I hit
the record Duplicate button it would help greatly.
 
Declare a variable at the module level (i.e.: at the very start of the
module, before any functions or subs), and increment it in the code on the
Duplication button's Click event.
 
Doug I apperciate the help man, but I dont know how to do VBA code. I am
mostly a hardware/networking guy I know some SQL but most of what you told me
is greek. Is there simpler way, or any chance you can take me though this one
step at a time?
 
Something along the lines of

Option Compare Database
Option Explicit

Private mintDuplicatesMade As Integer

Private Sub cmdDuplicate_Click()

' Code to do the duplicate

mintDuplicatesMade = mintDuplicatesMade + 1
Me.txtDuplicates = mintDuplicatesMade

End Sub

Private Sub cmdReset_Click()

mintDuplicatesMade = 0

End Sub

Private Sub Form_Load()

Call cmdReset_Click

End Sub

This assumes there's a field named txtDuplicates on the form that will show
how many duplicates have been made. It also assumes a Reset button, so that
you can set the value to 0 when you start copying a different record.
(Resetting the counter to 0 can be automated when you move from one record
to another: you'd put code in the form's Current event)
 
Back
Top