Conditional auto populating a field

Archie999

Access Wannabee
Local time
Yesterday, 22:34
Joined
May 25, 2003
Messages
45
Hi All,

I have a form in which I am having some trouble achieving my goal of auto populating a date field based on a condition determined by a different field.

The condition is stored in a field called 'status' and one of the status' is 'Closed'. If someone selects close I would like the IssueCloseDate to automatically populate with today's date... but only if the IssueCloseDate is already NULL. If it is populated then do nothing.

I tried adding the following code to the after update event of the status field. I'm positive it's wrong but need some help with the correct code. Thanks very much in advance!

Private Sub Status_AfterUpdate()
If Not Me!IssueCloseDate Then
End Sub
ElseIf Me!Status = 2 Then
Me!IssueCloseDate = Now()
End If
End Sub
 
Change the first "end sub" to "exit sub" and your code should work.

"end sub" tells the compiler that it's at the end of the code for the current subroutine. With your code, the compiler doesn't know what to do with the code following the first "end sub."
 
...and replace
If Not Me!IssueCloseDate
with
If Not IsNull(Me!IssueCloseDate)
 

Users who are viewing this thread

Back
Top Bottom