Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button-hit counter

Status
Not open for further replies.

matpj

Technical User
Mar 28, 2001
687
GB
I have a command button called CallCount
and a text box called Tally

I am trying an OnClick event:

Tally = Tally + 1

so that each time the button is pressed, 1 is added to the Tally text box.

The code does not produce any errors, but at the same time, does not put anything in the field, no matter how many timesI press it!

any ideas?
 

Mat,

I would create a new table with [autonumber], [date], [time] fields to record not only how many hits but the time and date you recorded them for later reporting.

All you have to do is set your Tally field control source to [autonumber].

Hope that helps

Donny
 
Donny, that is exactly what I am looking for, but what code do I use, and where?

I have a new table called Repeat Calls
I have two fields:
CallDateTime (Date/Time)
Counter (Autonumber)


On my form, I have a text box with its control source set to the Counter field (above)

what do I need to do inorder to make the button produce a new record in the Repeat Calls table on each click?
 
Mat,

In your table create another field [Hit]. Enter "Hit" into the first entry. (this will serve as replicatable data)

On your form - apply the followiing code to your command button "on Click"

Private Sub Command5_Click()
On Error GoTo Err_Command5_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_Command5_Click:
Exit Sub

Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub


Make sure your [tally] field control source is set to [autonumber], and it will display the hits whilst recording date and time for you!!

see how you go

Donny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top