What's wrong with this function

M

Minnow

It tells me a runtion error "5" and the debugger highlighted the line "If
u="L" then".

Function LitersProcessed(ByVal u As String, ByVal r1 As Double, ByVal r2 As
Double) As Double
Dim lp As Double

If u = "L" Then
lp = r2 - r1
Else
lp = HourToLiter(r2 - r1)

End If


LitersProcessed = lp
End Function
 
D

Douglas J. Steele

The only error I got is that HourToLiter is undefined (and that went away
when I put in a dummy declaration for the function)

I'm assuming you're getting the error when you call the function. How are
you calling it?

(BTW, there was no reason to post this question multiple times in multiple
newsgroups)
 
M

Minnow

HourToLiter(u as double) is another function I defined in the same Module and
it can be called in a query without any problem. But when
LitersProcessed(u,r1,r2) was called in query, I got a error with the line "If
u="L" then".

Is it because the function in same module is called?
 
D

Douglas J. Steele

There's no issue with functions calling other functions in either the same
modules or in other ones.

What did you name the module where you saved the 2 functions?
 
M

Minnow

Now, they are in different modules, one is called "Hour to Liter", the other
is called "Liters Processed".
 
M

Minnow

There are no names duplicated.

Douglas J. Steele said:
The only error I got is that HourToLiter is undefined (and that went away
when I put in a dummy declaration for the function)

I'm assuming you're getting the error when you call the function. How are
you calling it?

(BTW, there was no reason to post this question multiple times in multiple
newsgroups)
 
Top