Don,
1. Since I don't know what the button is for, I have to make an assumption
for the sake of providing an answer. If the button is for, let's say,
activities, you should create a new table called, let's say,
tblButtonClicks. Give it the following fields:
ButtonClickID (Autonumber - Primary Key)
ButtonClickCount (Integer)
2. Assuming your button is called myButton, do the following:
a) Open the form in design view.
b) From the View menu, select Properties. The Properties dialog is
displayed.
c) Click the button.
d) Select the Event tab on the Properties dialog.
e) Click in the textbox for On Click. You'll notice two buttons appear
on the right-hand-side.
f) Click the rightmost button.
g) If the Choose Builder dialog displayed, click Code Builder, then
click OK. You'll notice the procedure stub has been created for you.
h) Add the following between Private Sub... and End Sub.
Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT ButtonClickCount FROM tblButtonClicks " & _
"WHERE SomeIdentifier = " & someotheridentifier
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
If rs.AbsolutePosition > -1 Then
If rs!ButtonClickCount = 2 Then
'do whatever you want
rs.Delete
Else
rs.Edit
rs!ButtonClickCount = rs!ButtonClickCount + 1
rs.Update
End If
Else
rs.AddNew
rs!ButtonClickCount = 1
rs!someidentifier = someotheridentifier
rs.Update
End If
rs.Close
Set rs = Nothing
Set db = Nothing
i) Close the code screen.
j) Save the form.
Regards,
Graham R Seach
Microsoft Access MVP
Canberra, Australia
---------------------------