Vivienne
Just off the top of my head, I've had problems with conflicts of control
name and field name, more on reports than on forms. That is, if you drag a
field from the field chooser thingy onto a report it is automatically given
the same name as the field. So then when you come to refer to it in an
expression you might be referring to the control, not a field in the table.
I often end up renaming the controls txtFieldName.
Have you tried just evaluating SaturdayHours in the debug window, to find
out if your problem is with the function, rather than the report? Oh ,sorry,
you've run it as a query.
SaturdayHours looks a bit numeric to me. Are you sure you wouldn't be better
forcing nulls to a numeric 0 rather than an empty string? Though I don't
know how SaturdayHours works. Or making the last argument optional?
By the way. The naming of the functions implies to me that you're writing
functions to account for different rates of pay for different 'special'
times of work. I'd try to get that sort of information into tables. If you
can:
tblRatesByDayOfWeekOrHoliday:
WorkDate Rate
Monday 1.0
..
..
Friday 1.0
Saturday 1.5
Sunday 1.5
BH 2.0
XmasDay 2.0
NYDay 2.0
Then some function, highestRate (workDate) that for any day finds what the
highest rate is for that particular date.
Then your calculating function calls highestRate x hoursWorked. Or
something.
Of course you will need a table of bank holidays (or dates that you pay at
the bank holiday rate). But the rest can be got from the date.
Mike
"VivN" <vi*****************@whnt.nhs.uk> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I want to use an expression as the control source for a text box in a
report (Access 2000).
Whilst I have sucessfully used these simple ones
=TimeToSingle(TotalHours([TimeFrom],[TimeTo]))
=TimeToSingle(BHolHours([dtmShiftDate],[timefrom],[timeto]))
I get problems when I include a text parameter Scale (control just
displays #error)
=TimeToSingle(SaturdayHours([dtmShiftDate],[timefrom],[timeto],[Scale]))
Where TotalHours, BHolHours and SaturdayHours are user defined
functions.
[Scale] is either null or has a value.
I tried forcing [Scale] to be an empty string (if scale is null)
without success.
If I change the parameter type in the function call to variant, the
parameter value is error 0 at run time (type mismatch).
The function runs fime if used to calculate the value as a calculated
column in a query.
Is this expression too complicated for a report field control source?