OK Mary10k . . . . .
The following will update [blue]
Start/End Time[/blue] as you've prescribed . . . . at least as far as these fields of the RecordSource of the form are concerned! Table structure & names may be required if a seperate history table from that of the form (as I suspect) is involved.
Note: The [purple]
updates are done in the background[/purple] as [blue]
I don't believe this is something you want in view for users to see[/blue]. If this is not so, then slight modifications will have to be made to the code . . . here's the steps:
[ol][li][purple]
Add a TextBox[/purple] to the form (perferably in the form header or footer). [purple]
Delete the Label[/purple] of the textbox. Set the following properties for the textbox:
[ol a][li][purple]
Left[/purple] 0[/li]
[li][purple]
Top[/purple] 0[/li]
[li][purple]
Width[/purple] 0[/li]
[li][purple]
Height[/purple] 0[/li]
[li][purple]
Name[/purple] PrevID[/li][/ol][/li]
[li] In the [blue]
On Dirty Event[/blue] of the form, copy/paste the follwoing code (in all code . . . [blue]
you[/blue] substitute proper names in [purple]
purple[/purple]):
Code:
[blue] Me!StartTime = Now()
Me!PrevID = Me![purple][b]PrimaryKeyName[/b][/purple][/blue]
[/li]
[li]Next . . . in the [blue]
On Current Event[/blue] of the form, copy/paste the following code:
Code:
[blue] Dim SQL As String
If Trim(Me!PrevID & "") <> "" Then
SQL = "UPDATE [purple][b]TableName[/b][/purple] SET EndTime = Now() " & _
"WHERE ([purple][b]PrimaryKeyName[/b][/purple]=" & Me![PrevID] & ");"
DoCmd.RunSQL SQL
Me!PrevID = ""
End If[/blue]
[/li][/ol]
Again, the times are set in the background. Believing you have another form for viewing these times, they should show there.
[blue]Thats it! . . . . give it a whirl & let me know! . . . .[/blue]
See Ya! . . . . . .