Now Date in IF statement

G

Guest

Hi all,
I would like to be able to control the Complition Date on the form according
to the Status field, that meens that: when the Status is "Completed",
Completed Date Field will uptade the corrent date Or else leave blank.
I have tried to put the calculation on the control source on the field
properties:
=iif([Status]="Completed",=Now(),"")
But it doesn't work.

I have tried also to put it as After Update Event Procedure:
Private Sub Completion_Date_AfterUpdate()
If Me.Status = "Comp-Completed" Then
Completion_Date = Now()
End If
End Sub

But this is not working as weel.
What am I missing?

Thanks very much for the help.
 
F

fredg

Hi all,
I would like to be able to control the Complition Date on the form according
to the Status field, that meens that: when the Status is "Completed",
Completed Date Field will uptade the corrent date Or else leave blank.
I have tried to put the calculation on the control source on the field
properties:
=iif([Status]="Completed",=Now(),"")
But it doesn't work.

I have tried also to put it as After Update Event Procedure:
Private Sub Completion_Date_AfterUpdate()
If Me.Status = "Comp-Completed" Then
Completion_Date = Now()
End If
End Sub

But this is not working as weel.
What am I missing?

Thanks very much for the help.

You need to code the [Status] control's AfterUpdate event.
Is [Status] a Text datatype field?
Then:

Private Sub Status_AfterUpdate()
If Me.Status = "Completed" Then
Me.Completion_Date = Now()
End IF
End Sub

However, if [Status] is a Check Box field, then:

If Me.Status = True then
....etc...
 
G

Guest

thank you for the quick response and the help. I understood where was my
problem.
thanks again.

fredg said:
Hi all,
I would like to be able to control the Complition Date on the form according
to the Status field, that meens that: when the Status is "Completed",
Completed Date Field will uptade the corrent date Or else leave blank.
I have tried to put the calculation on the control source on the field
properties:
=iif([Status]="Completed",=Now(),"")
But it doesn't work.

I have tried also to put it as After Update Event Procedure:
Private Sub Completion_Date_AfterUpdate()
If Me.Status = "Comp-Completed" Then
Completion_Date = Now()
End If
End Sub

But this is not working as weel.
What am I missing?

Thanks very much for the help.

You need to code the [Status] control's AfterUpdate event.
Is [Status] a Text datatype field?
Then:

Private Sub Status_AfterUpdate()
If Me.Status = "Completed" Then
Me.Completion_Date = Now()
End IF
End Sub

However, if [Status] is a Check Box field, then:

If Me.Status = True then
....etc...
 
J

John W. Vinson

thank you for the quick response and the help. I understood where was my
problem.

One thing to note: Now() does NOT return today's date. It returns the current
date and time, accurate to a few microseconds. If you just want the date, use
Date() instead.

John W. Vinson [MVP]
 
G

Guest

John, thanks a lot for the advice. That exactly what I did. I already changed
it to Date().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top