Count Command Button Clicks

PeteK

New member
Local time
Today, 18:23
Joined
Oct 21, 2011
Messages
5
Hi,
I have a number of forms in a dbase and all of them include command buttons that, when clicked, print a label (report wizard). I would like to establish how many labels are printed daily hence would like a count of some sort everytime a label is produced. Post label printing, the form in question closes and the record is deleted - a security request of the user. Hence no data is ever stored in a table. The onclick functions for each command already have commands against them forprinting of the label. Does anyone have any suggestions with regard to counting number of labels produced? Many thanks.
 
PeteK,

How do the labels get printed? Are they printed immediately a button on a form is clicked?

Or

Is the report opened and users can print however many they wish using the in-built Print menus?
 
Labels are printed immediately - there is a prompt as to how many copies are required as the labels report is linked toa query where the prompt for number of copies is asked. The report is not previewed.
 
So why not just get the number from the textbox and perform an incremental UPDATE to a table to store the count for that day?
 
Apologies, being dense here. What textbox and how would I perform an incremental update to a stand alone table?
 
Let me just get something straight. You want to count how many labels are printed as opposed to how many times the print button is clicked?
 
Ideally labels but if clicking the print button is easier then so be it.
 
... the labels report is linked toa query where the prompt for number of copies is asked ...

If you want to have access to the number of copies the user provides, you will have to change the way you are prompting for the number of copies. When you have the prompt in the query, it is not as easy to capture the number provided by the user.

I would suggest that you create a form and prompt the user for the copy count using a text box on the form. Then you can capture the number entered by the user. You can also add a field to a table that will hold a number that you can update each time they print labels.
 
Not exactly a columnar report. It is designed in the form of a label. Fields in rows.
 
So you need to:

1. get the total number of labels printed by placing a textbox in the report's Footer section and entering =Count(*) in the Control Source. Call it txtCountAll.
2. Declare a variable in the report's Declaration section:
Code:
Option Compare Database
Option Explicit
 
Private hasSaved As Boolean
3. Then in the Format event of the Report Footer section, put this code:
Code:
If hasSaved = False Then
    CurrentDb.Execute("UPDATE [TableName] " & _
                      "SET [CountField] = [CountField] + " & Val(Me.[B]txtCountAll[/B]) & " " & _
                      "WHERE [DateField] = Date();", dbFailOnError)
    hasSaved = True
End If
 

Users who are viewing this thread

Back
Top Bottom