How do I populate current date based on another fields output?

S

Selli

I am trying to automatically populate a date field only when a specific
"status" is chosen. i.e. if Status = "Closed" then Resolved Date = Date()
(current date). If status <> closed then Resolved date is null. This would
be a form filed.
 
L

Linq Adams via AccessMonster.com

Private Sub Status_AfterUpdate()
If Me.Status = "Closed" Then
Me.[Resolved Date] = Date()
End If
End Sub

Note: The square brackets around

Resolved Date

are necessary because of the space between the 2 word name. You really ought
avoid object names with spaces and eith ResolvedDate or Resolved_Date.
 
T

Tom van Stiphout

On Mon, 21 Jul 2008 18:06:03 -0700, Selli

In the Status field's AfterUpdate event write:
if Me.Status = "Closed" then
Me.[Resolved Date] = Date()
else
Me.[Resolved Date] = Null
end if
(of course you need to double-check the control names)

-Tom.
Microsoft Access MVP
 
Top