Solved

Code to show when the button was last clicked in access form

Posted on 2013-11-26
4
1,006 Views
Last Modified: 2013-11-26
I need some code that generates text of when the button was last clicked.

Bottom line, the button is linked to a query and I need to know when the query was last run

so
button1 - button that runs the query
field1 the field that shows when the last time button 1 was clicked



thanks in advance,
Vinnie
0
Comment
Question by:damixa
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39677884
private sub button1_click()

currentdb.execute "update tableName set field1=Now()"

me.field1.refresh
end sub
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39677900
Do you mean last clicked during the current session, or ever, by any user?

Generally, if you want to track application functionality and use, you create a separate table in your database for that, and then add code to events (Form_Open, Report_Open, cmd_XXX_Click, ...) which will populate that table.

I generally include fields for:

Form_Name
Event_Name
Event_DateTime
User_Name

Best way is to write a subroutine that writes to this information to the table and just call that subroutine from within each of the events you want to track.
0
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 39677901
You can add something like this to your button:

Private Sub CommandButton1_Click()
   Me.Text1.Value = Now()
End Sub

Flyster
0
 

Author Closing Comment

by:damixa
ID: 39677962
Thanks Ton. This is what I was looking for!
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question