Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-11-26
4
Medium Priority
?
1,083 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 49

Expert Comment

by:Dale Fye
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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

876 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