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
Thanx in advance!
sc
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
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.
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
Me![YourStartTimeFieldName
End Sub
Private Sub btnStop_Click()
Me![YourStopTimeFieldName]
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
End Sub
Private Sub btnStop_Click()
Me("YourStopTimeFieldName"
End Sub
ASKER
Perfect! Simple steps if you know where to look :)
Thanx.
sc
Thanx.
sc
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