Can't use function in a report

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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










.



Relevant Pages

  • Re: Cant use function in a report
    ... prints with just bonus, I see good non-null, non-zero data. ... I went back several generations to a copy of the report that didn't ... There is a filter ...
    (microsoft.public.access.gettingstarted)
  • Re: Cant use function in a report
    ... variable was how I made the change, not which version of the report I used. ... simple [bonus] item in the detail and then put the ... Public Function fncTranslateTokens(adc_Tokens As Variant) ... fncTranslateTokens = Failure ...
    (microsoft.public.access.gettingstarted)
  • Re: Horrendous Audio Stutter - current git
    ... Under kernel compilation load audio is very much unusable ... However that in itself has a flaw, we're comparing vruntime to process ... So what we do is _shrink_ the bonus the busier we get (the more tasks we ... So by default we have both enabled; could you report if either ...
    (Linux-Kernel)
  • Re: Cant use function in a report
    ... My problem is that if I try to put the Bonus into a function, ... =sumin the footer of the report works fine. ... Public Function fncTranslateTokens(adc_Tokens As Variant) ... fncTranslateTokens = Failure ...
    (microsoft.public.access.gettingstarted)
  • Re: Someones got to crawl out from under the brdge and say it
    ... Aren't the games usually in New Zealand, Simon? ... You're failure to secure a bonus point yesterday doesn't convince me it would have been a problem. ...
    (rec.sport.rugby.union)