G
Guest
I have a function using DLOOKUP which looks up numbers. If the value cannot
be found I want the function to equal zero. I tried the following but it does
not work.
Function myFX(mySource As Integer, myDestination As Integer)
myFX = CDbl(DLookup("[FinStdRate]", "tbl_Currency", "[SourceCountryID]=" &
mySource & " And [CountryID] = " & myDestination))
If iserror(myFX) then
myFX = 0
Endif
End Function
However when I leave out the If statement in the VBA and add it to my text
field in my form it does work.
i.e.
=IIf(IsError(myFX),0,myFX)
Why doesnt this work in VBA? Is their another way to do this?
Bruce
be found I want the function to equal zero. I tried the following but it does
not work.
Function myFX(mySource As Integer, myDestination As Integer)
myFX = CDbl(DLookup("[FinStdRate]", "tbl_Currency", "[SourceCountryID]=" &
mySource & " And [CountryID] = " & myDestination))
If iserror(myFX) then
myFX = 0
Endif
End Function
However when I leave out the If statement in the VBA and add it to my text
field in my form it does work.
i.e.
=IIf(IsError(myFX),0,myFX)
Why doesnt this work in VBA? Is their another way to do this?
Bruce