Link to home
Start Free TrialLog in
Avatar of Gocsteve1
Gocsteve1

asked on

Need a simple Button to Timestamp

Hello,  I am trying to get a button to drive a date/timestamp (mm/dd/yyyy 00:00:00) of a field in Access 2010.  I can't seem to figure it out, and however it seems like something I should be able to find by googling or watching YouTubes on Access..... I have had zero luck finding it.  (probably because its so simple :)

Thanx in advance!

sc
Avatar of Tapan Pattanaik
Tapan Pattanaik
Flag of India image

Hi Gocsteve1

Please check this link.

Format the date and time field in Access:

http://office.microsoft.com/en-us/access-help/format-the-date-and-time-field-in-access-HA010341474.aspx
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
What do you mean by 'a button to drive a date/timestamp' ?

IF ... you are trying to get when a record was created or last modified - then do this (this is just a wild guess as to what you want):

Private Sub Form_BeforeUpdate (Cancel As Integer)

    If Me.NewRecord = True then
         Me![DateCreated] = Now()    ' assuming field is called DateCreated
    Else
        Me![DateLastModified] = Now()  ' assuming field is called DateLastModified
    End If

End Sub
ASKER CERTIFIED SOLUTION
Avatar of Chris B
Chris B
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gocsteve1
Gocsteve1

ASKER

This is a simple schedule database.... I'm adding a start and stop button to track the work associated with the task shown (the other fields)

 There is no other data being manipulated, so I need these two buttons to stamp 2 fields.  First now() is the start of the task, the second at the completion of the task.  Make sense?

There are 17 tasks this admin is performing, and I'm trying to understand how long they take.

SC
Just to add more clarity....

I only want a start and stop button on my form that link to the start and stop time fields....pressing the start date time stamps to the start time field..... Pressing the stop button date time stamps to the stop time field.
Private Sub btnStart_Click()
    Me![YourStartTimeFieldName] = Now()
End Sub

Private Sub btnStop_Click()
    Me![YourStopTimeFieldName] = Now()
End Sub

This will put the values in a field in your table. If you are just talking about a text box on a Form (and maybe also storing in a field):



Private Sub btnStart_Click()
    Me("YourStartTimeFieldName") = Format(Now(), "mm/dd/yyyy 00:00:00")
End Sub

Private Sub btnStop_Click()
    Me("YourStopTimeFieldName") = Format(Now(), "mm/dd/yyyy 00:00:00")
End Sub
Perfect!  Simple steps if you know where to look :)

Thanx.

sc