Nested If - Multiple conditions

  • Thread starter Thread starter Rod
  • Start date Start date
R

Rod

How can I write multiple conditions on access97!

I am trying to get a function F(X,Y,Z)as variants
where they are all dates!

What I need is something like: Function is equal
to "formula" only if two conditions are met:

IF((Y = Z) AND ((Month(X)) < (Month(Z))),(F = CDate((Month
(X)) & "/" & Day(X) & "/" & (Year(Z) + 1))),0),0))

Any help will be appreciatted
 
Rod said:
How can I write multiple conditions on access97!

I am trying to get a function F(X,Y,Z)as variants
where they are all dates!

What I need is something like: Function is equal
to "formula" only if two conditions are met:

IF((Y = Z) AND ((Month(X)) < (Month(Z))),(F = CDate((Month
(X)) & "/" & Day(X) & "/" & (Year(Z) + 1))),0),0))

The "multiple conditions" are fine, it's the If syntax
that's out of whack.

Public Function F(X As Date,Y As Date,Z As Date) As Date
If (Y = Z) AND ((Month(X) < (Month(Z)) Then
F = DateSerial(Year(Z) + 1, Month(X), Day(X))
Else
F = 0
End If
End Function

(I prefer DateSerial over CDate of a concatenated string)

The only reason to use Variant here is in case an argument
can be Null, but you have made no provision for dealing with
Null values.
 
Back
Top