L
Laurel
I have a simple report that prints a date and a value (columnname 'bonus')
in its detail section. It seems to work fine. My problem is that if I try to
put the Bonus into a function, I get an error. I've tried the simplest
Access functions, such as =abs(Bonus) and =format([bonus],"##.#"). In those
cases, the report prints
#Error instead of the value of Bonus. If I try to use a function written by
me, (=fncTranslateTokens([bonus]), I get this VB error: "2427 - You have
entered an expression that has no value." And, indeed, if I look at the
parameter in the function via the debugger, it has no value - doesn't show
null or anything.
Here are possibly relevant facts.
=sum([bonus]) in the footer of the report works fine.
I've removed [bonus] from the detail, saved, and then re-added it.
I've "comact and repair"ed the database
Recordsource for the report is a query
There is a filter
But remember that the report works fine - good data - if I just use
[bonus] or bonus
bonus is a datatype: number, field Size: integer
This is the text of the function written by me that I'm trying to use. I've
declared the parameter as a variant, but at first I wasn't declaring it at
all. The control goes to the error handler which prints the message.
Reminder - can't use format(bonus,"##.#") or abs([bonus]) either, so the
problem
isn't limited to this function.
Public Function fncTranslateTokens(adc_Tokens As Variant)
Dim ls_temp As String
Dim lv_temp As Variant
On Error GoTo Err_TranslateTokens
If IsNull(gdc_TokenValue) Or gdc_TokenValue <= 0 Then
MsgBox ("Please enter avalue for the parameter 'TokenValue.'")
fncTranslateTokens = Failure
GoTo Exit_TranslateTokens
End If
fncTranslateTokens = Format(gdc_TokenValue * adc_Tokens, "$#,##0.00")
Exit_TranslateTokens:
Exit Function
Err_TranslateTokens:
If IsNull(adc_Tokens) Then
ls_temp = "Null"
Else
ls_temp = adc_Tokens
End If
ls_temp = "fncTranslateTokens:" & " adc_tokens: " & lv_temp _
& vbCrLf & Err.Description
MsgBox ls_temp
fncTranslateTokens = Failure
Resume Exit_TranslateTokens
End Function
in its detail section. It seems to work fine. My problem is that if I try to
put the Bonus into a function, I get an error. I've tried the simplest
Access functions, such as =abs(Bonus) and =format([bonus],"##.#"). In those
cases, the report prints
#Error instead of the value of Bonus. If I try to use a function written by
me, (=fncTranslateTokens([bonus]), I get this VB error: "2427 - You have
entered an expression that has no value." And, indeed, if I look at the
parameter in the function via the debugger, it has no value - doesn't show
null or anything.
Here are possibly relevant facts.
=sum([bonus]) in the footer of the report works fine.
I've removed [bonus] from the detail, saved, and then re-added it.
I've "comact and repair"ed the database
Recordsource for the report is a query
There is a filter
But remember that the report works fine - good data - if I just use
[bonus] or bonus
bonus is a datatype: number, field Size: integer
This is the text of the function written by me that I'm trying to use. I've
declared the parameter as a variant, but at first I wasn't declaring it at
all. The control goes to the error handler which prints the message.
Reminder - can't use format(bonus,"##.#") or abs([bonus]) either, so the
problem
isn't limited to this function.
Public Function fncTranslateTokens(adc_Tokens As Variant)
Dim ls_temp As String
Dim lv_temp As Variant
On Error GoTo Err_TranslateTokens
If IsNull(gdc_TokenValue) Or gdc_TokenValue <= 0 Then
MsgBox ("Please enter avalue for the parameter 'TokenValue.'")
fncTranslateTokens = Failure
GoTo Exit_TranslateTokens
End If
fncTranslateTokens = Format(gdc_TokenValue * adc_Tokens, "$#,##0.00")
Exit_TranslateTokens:
Exit Function
Err_TranslateTokens:
If IsNull(adc_Tokens) Then
ls_temp = "Null"
Else
ls_temp = adc_Tokens
End If
ls_temp = "fncTranslateTokens:" & " adc_tokens: " & lv_temp _
& vbCrLf & Err.Description
MsgBox ls_temp
fncTranslateTokens = Failure
Resume Exit_TranslateTokens
End Function