Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then, elseif then, Else statement

Status
Not open for further replies.

moswitch

Technical User
Feb 26, 2007
40
US
I have the follow Access expression which I would love to convert to a If then, elseif then, Else expression. How would I go about doing that, I'm having difficulties doing so.

Return iif([A] <= "1/1/1900",year(now()) - year(),iif([A]="",year(now()) - year(), year(now()) - year([A])))


Thank you in advance.
 
If varA <= #1900-01-01# Or IsNull(varA) Then
Return = Year(Now) - Year(varB)
Else
Return = Year(Now) - Year(varA)
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

Hi,
[tt]
iif([A] <= "1/1/1900",year(now()) - year(),iif([A]="",year(now()) - year(), year(now()) - year([A])))

If([A] <= "1/1/1900" Then
year(now()) - year()
Else
If ([A]="" Then
year(now()) - year()
Else year(now()) - year([A])))
[/tt]
However, you have a fundamental logical error in this statement...
[tt]
[A] <= "1/1/1900"
[/tt]
A Date is not a string!!!

This might work...
[tt]
[A] <= DateValue("1/1/1900")
[/tt]



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
For some reason the software I'm using is giving me a
Compiler found (2) errors in the expression.
Expression expected.
Expression expected.
 
I could easly write my expression as a VBA statement but the software I'm using seems to only like expressions. I'm not familier with expressions at all for MS Access. The replys which were posted seem to make since but for some reason the compiler is finding something wrong with it.
 
Which software ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It is an in house program, but not to worry I've solved the problem. Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top