What's going on with Format?

  • Thread starter Thread starter Laurel
  • Start date Start date
L

Laurel

I have a report that prints percent of days absent. I want to switch it to
percent of days present, but I get unexpectedly large numbers. It seems I
don't understand how the ## format works.

'The old way of doing it
fncDaysAbsentPercent = Format((Val(ls_absent) / Val(ls_enrolled)), "###%")
ls_absent = '1'
ls_enrolled = '8'
fncDaysAbsentPercent = 13%

'The new way of doing it
fncDaysPresentPercent = Format(100 - ((Val(ls_absent) / Val(ls_enrolled))),
"###%")
ls_absent = '1'
ls_enrolled = '8'
fncDaysPresentPercent = 9988%

I think I must have stumbled on a way of displaying absent percentages which
"worked" accidentally. Using numeric variables doesn't seem to help. The
following also gives me an unexpectedly large number.

ldc_debug = Val(ls_absent) / Val(ls_enrolled)
ldc_debug = 100 * ldc_debug 'This
equals 12.5
fncDaysPresentPercent = Format(ldc_debug, "###.##%") 'This
equals 1250.%
 
Try
fncDaysPresentPercent = Format(1 - ((Val(ls_absent) /
Val(ls_enrolled))), "###%")

100% is 1
100 is 10000 percent



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
try the following, as

Format(((Val(ls_enrolled)-Val(ls_absent)) / Val(ls_enrolled)), "###%")

hth
 
Thanks. That was it.

John Spencer said:
Try
fncDaysPresentPercent = Format(1 - ((Val(ls_absent) / Val(ls_enrolled))),
"###%")

100% is 1
100 is 10000 percent



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
Back
Top