Writing vbAND function (1 Viewer)

sportsguy

Finance wiz, Access hack
Local time
Today, 09:52
Joined
Dec 28, 2004
Messages
358
greetings everyone from new england where we will get the second significant snow storm since oct 31 last year.

I want to write a vbAND function for access which works like the AND(condition1, condition2) in excel.

But before I start, does anyone know of one already written?

the query would look like this
PositiveRate: Iif(vbAnd([field1]>[Field2],[Field3]=[Field4]),[Amount],0)

thanks,

sportsguy
 

sportsguy

Finance wiz, Access hack
Local time
Today, 09:52
Joined
Dec 28, 2004
Messages
358
I guess it would look like this:

Code:
Function vbAnd(expr1 As Boolean, expr2 As Boolean) As Boolean

If expr1 = True And expr2 = True Then
    vbAnd = True
Else
    vbAnd = False
End If

End Function

sportsguy
 

sportsguy

Finance wiz, Access hack
Local time
Today, 09:52
Joined
Dec 28, 2004
Messages
358
Code:
Function vbAnd(expr1 As Boolean, expr2 As Boolean) As Boolean


If expr1 = True And expr2 = True Then
    vbAnd = vbTrue
Else
    vbAnd = vbFalse
End If

End Function

Function vbAnd3(expr1 As Boolean, expr2 As Boolean, expr3 As Boolean) As Boolean


If expr1 = True And expr2 = True And expr3 = True Then
    vbAnd = vbTrue
Else
    vbAnd = vbFalse
End If

End Function

done, i guess, couldn't figure out how to make expr3 optional and identify it when null to skip it

sportsguy
 

Users who are viewing this thread

Top Bottom