Trying to update date to current whenever a specific condition is met...

elektrik

Registered User.
Local time
Today, 00:37
Joined
Mar 22, 2000
Messages
22
Hi all. I am trying to figure out the code for the following problem: I have a "Closed Date" text box that I want updated to the current date and time ONLY when someone selects "Closed" from a combo box control on the same form. Anyone have any ideas how I do this with VB? I have what I thought was the correct code below, but it didn't work.

Thanks in advance!
Jerry Horgan

Private Sub Closed_Date_Change()
If Bug_Status = "Closed" Then
Closed_Date = Now()
Else: Closed_Date = ""
End If
End Sub
 
Try using the Lost Focus event, and add this line of code.

If IsNull(Me.[Closed_Date]) = True Then
'Do your code
Else
'Do not change the date if a valid one is already present.
End If

It may be easier to provide the user with a checkbox control and make the closed status a Boolean field in the table. Then your check would be:
If chkBugStatusClosed = True Then

'I assume the Checkbbox name to be chkBugStatusClosed

Duane Barker
 
Got it. Thanks!
 

Users who are viewing this thread

Back
Top Bottom