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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ISEVEN

Status
Not open for further replies.

Joycelet

IS-IT--Management
Mar 26, 2003
79
GB
Hi

I've got a query where I need to show just even or just odd numbers - is there an ISEVEN Function in access, I've searched but I've had no joy so far

Thanks for any help

J
 
Try using the MOD operator...

[yournumber] MOD 2
- if this is equal to 0 then [yournumber] is even
- if this is equal to 1 then [yournumber] is odd

 
just for fun ...

Code:
Public Function basIsOdd(Optional varIn As Variant) As Boolean

    'Return True if the input value is an Odd Number, _
     Else Return False

    'Eliminate the obvious casual first
    If (IsNull(varIn)) Then
        Exit Function
    End If

    If (IsNumeric(varIn)) Then
        If ((CLng(varIn) Mod 2) <> 0) Then
            basIsOdd = True
        End If
    End If

End Function


MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top