Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1117
  • Last Modified:

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

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
damixa
Asked:
damixa
1 Solution
 
Rey Obrero (Capricorn1)Commented:
private sub button1_click()

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

me.field1.refresh
end sub
0
 
Dale FyeCommented:
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
 
FlysterCommented:
You can add something like this to your button:

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

Flyster
0
 
damixaAuthor Commented:
Thanks Ton. This is what I was looking for!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now