Counting how many times a button has been pressed

chrisbrooke

New member
Local time
Today, 05:03
Joined
Sep 4, 2003
Messages
9
Hello,

How do calculate how may times a button has been pressed. Ive tried setting a variable say count=0 when the form opens(event). Then simply iterate this count on the onclick (on the button in question) event. However, this dosent seem to work. Any ideas? Thanks in advance.
 
Code:
Private Sub cmdMyButton_Click()

    Static intClicked As Integer

    intClicked = intClicked + 1

    MsgBox "This button has been clicked " & _
        IIf(intClicked = 1, "time", "times") & ".", vbInformation, "Example"

End Sub
 
If you want to preserve it after closing the DB you will have to store it in the DB somewhere/somehow (try in a table :))...

Regards
 

Users who are viewing this thread

Back
Top Bottom