ElseIf statement

G

Guest

I'd like to create an If Elseif statement to display the Status with three
possible values. My query has a field for CancelDate and a field for
CompleteDate. I'd like to show the Status as Open, Complete or Cancel based
on these two fields.

I think it should look something like this, but obviously need help. I've
always used IIF, not Elseif.

If [Tasks]![TaskCompleteDate]>0 Then Complete
Elseif [Tasks]![TaskCancelDate]>0 Then Cancel
Else Open

Thanks for your help.

Mary
 
L

Lynn Trapp

If you are working in a query, you will have to use IIF:

IIF([TaskCompleteDate] > 0, "Complete",IIF([TaskCancelDate] > 0,
"Cancel","Open"))

You can use the If Then Else construction in a form.

If Me.TaskCompleteDate > 0 Then
Me.Status = "Complete"
Elseif Me.TaskCancelDate > 0 Then
Me.Status = "Cancel"
Else
Me.Status = "Open"
End If

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
G

Guest

You should use the iif within iif

IIf( [Tasks]![TaskCompleteDate]>0 ,"Complete", IIF
([Tasks]![TaskCancelDate]>0, "Cancel", "Open"))
 
G

Guest

Thanks!

Lynn Trapp said:
If you are working in a query, you will have to use IIF:

IIF([TaskCompleteDate] > 0, "Complete",IIF([TaskCancelDate] > 0,
"Cancel","Open"))

You can use the If Then Else construction in a form.

If Me.TaskCompleteDate > 0 Then
Me.Status = "Complete"
Elseif Me.TaskCancelDate > 0 Then
Me.Status = "Cancel"
Else
Me.Status = "Open"
End If

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html


Mary said:
I'd like to create an If Elseif statement to display the Status with three
possible values. My query has a field for CancelDate and a field for
CompleteDate. I'd like to show the Status as Open, Complete or Cancel
based
on these two fields.

I think it should look something like this, but obviously need help. I've
always used IIF, not Elseif.

If [Tasks]![TaskCompleteDate]>0 Then Complete
Elseif [Tasks]![TaskCancelDate]>0 Then Cancel
Else Open

Thanks for your help.

Mary
 
L

Lynn Trapp

You are quite welcome.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html


Mary said:
Thanks!

Lynn Trapp said:
If you are working in a query, you will have to use IIF:

IIF([TaskCompleteDate] > 0, "Complete",IIF([TaskCancelDate] > 0,
"Cancel","Open"))

You can use the If Then Else construction in a form.

If Me.TaskCompleteDate > 0 Then
Me.Status = "Complete"
Elseif Me.TaskCancelDate > 0 Then
Me.Status = "Cancel"
Else
Me.Status = "Open"
End If

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html


Mary said:
I'd like to create an If Elseif statement to display the Status with
three
possible values. My query has a field for CancelDate and a field for
CompleteDate. I'd like to show the Status as Open, Complete or Cancel
based
on these two fields.

I think it should look something like this, but obviously need help.
I've
always used IIF, not Elseif.

If [Tasks]![TaskCompleteDate]>0 Then Complete
Elseif [Tasks]![TaskCancelDate]>0 Then Cancel
Else Open

Thanks for your help.

Mary
 

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