Help Please - Capture CloseDateTime when status change (1 Viewer)

vicsalt

Registered User.
Local time
Today, 13:51
Joined
Aug 22, 2008
Messages
48
I am creating a maintenance database, break downs are raised, engineers select a job. They can log off the job so i can capture times etc. However Im now working on capturing the close date which is the time the break down was fixed .

I have a field in a table called "CloseDateTime" and display a form (based on a query) which has a status dropdown with Close/Open. I am trying to capture the "CloseDateTime" when the status changes from open to closed. I have tried for two days with no success and no VB programmer. Its the highlighted RED section


Option Compare Database

Private Sub LogOff_btn_Click()
EngEndTimeDate = Now()
Live = False
DoCmd.Close acForm, "EngJobList_frm"
DoCmd.Close acForm, "EngUpdate_frm"
End Sub

Private Sub Status_combo_AfterUpdate()
ClosedDateTime = Now()
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:51
Joined
Sep 21, 2011
Messages
14,306
You need to test the value of the combo before setting the control. I always use Me. for my controls
Better start getting used to putting Option Explicit in every module via VBA editor/Tools/Options/Require variabledeclaration, but that will only work on new modules. You need to amend existing ones manually.
 

vicsalt

Registered User.
Local time
Today, 13:51
Joined
Aug 22, 2008
Messages
48
sorry need more basic advice :( example ?
 

LarryE

Active member
Local time
Today, 05:51
Joined
Aug 18, 2021
Messages
591
Code:
Private Sub Status_combo_AfterUpdate()
If Me.Status_combo = "Close" Then
    ClosedDateTime = Now()
End If
End Sub
 

vicsalt

Registered User.
Local time
Today, 13:51
Joined
Aug 22, 2008
Messages
48
Code:
Private Sub Status_combo_AfterUpdate()
If Me.Status_combo = "Close" Then
    ClosedDateTime = Now()
End If
End Sub
Thankyou so much i did discover a issue in that the field "CloseDateTime" wasnt in the query . I have used your code and it works perfect, thankyou i can now switch off work !
 

Users who are viewing this thread

Top Bottom