Nested If - Multiple conditions

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
 
M

Marshall Barton

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.
 

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