View Single Post
  #2 (permalink)  
Old September 28th, 2005, 06:03 AM
SteveH SteveH is offline
Registered User
Join Date: Sep 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts


The IIF (Built-In) function in Access won't give you the results you are looking for. If you try to use the function, it will generate an #Error as well. To resolve this issue I created a function. Here's the code:

Function DivideByZero(Numerator As Double, Denominator As Double) As Double

    Dim dblResults As Double

    If Numerator = 0 Or Denominator = 0 Then
        dblResults = 0
        dblResults = Numerator / Denominator
    End If

    DivideByZero = dblResults

End Function

The statement will return the value of zero if either input is zero.
Reply With Quote