how to log switchboard button clicks

J

Jimbo213

We have reports and extracts-to-excel controlled by buttons on various
second and third level switchboards. We'd like a way to see the last time a
report or extract was run ... ie: when was the last date-time that a
switchboard button was pressed.

In this way we could say "ok remove that button (report) - it hasn't been
pressed for 15 months" or we could move that button to an "archive"
sub-switchboard.

What's the best way to do that?

Thanks for your reply & assistance.
Jimbo213
 
P

Piet Linden

We have reports and extracts-to-excel controlled by buttons on various
second and third level switchboards.  We'd like a way to see the last time a
report or extract was run ... ie:  when was the last date-time that a
switchboard button was pressed.

In this way we could say "ok remove that button (report) - it hasn't been
pressed for 15 months" or we could move that button to an "archive"
sub-switchboard.

What's the best way to do that?

Thanks for your reply & assistance.
Jimbo213

write a sql statement to do the insert... and execute it on the button
click.
If you use

DBEngine(0)(0).Execute strsql

you don't have to worry about shutting off messages - like the ones
queries throw. Then you can just change a few things in your insert
statement, depending on what button you attached the code to.

the statement is something like
Sub LogClicks(byval strButtonName as string)
dim strsql as string

strsql= "INSERT INTO MyLogTable(strButtonName, WhenClicked) VALUES ('
" & strButtonName & "," & Now() & ")"
'or set the default of WhenClicked in your table to NOW)
then your call would be

Sub cmdMyButton_Click()
LogClicks "MyButton"
...do whatever
End Sub
 
P

PJFry

On a very high level, put into the OnClick even for that switchboard item an
SQL append statement that would write a date/time stamp to a table.

Create a table, say tLog, with three fields, ID as an AutoNum, dtmUsed as
Date/Time and txtControlName as String. Then on the OnClick event, you will
put in code to record that button push:

Dim sSQL As String

DoCmd.SetWarnings False

sSQL = "INSERT INTO tLog (dtmUsed,txtControlUsed) VALUES('" & Now() &
"','ButtonName')"

DoCmd.RunSQL sSQL

DoCmd.SetWarnings True

You would need to do this for each of the buttons you are monitoring.

There might be a way to record the active control instead of adding the
'ButtonName', but I am not sure what it is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top