Dividing two integer numbers

  • Thread starter Thread starter Joan
  • Start date Start date
J

Joan

I have a control in the report footer where I want to divide one total in
the report footer by another total in the footer. In the report instance
that I am working with, one of the totals is 420 and the other is 797. When
I divide 420 by 797 ,( the control source is = ([DReceived]/[DBooked]).,
the result is 0.5. I'd like this result to show 4 decimal places ( For
example: .5270 ) because I would like to display this result as a
percentage in my report. . Currently, if I select "Percentage" as the
format in the control's property sheet, the result is displayed as 50.00%.
I want it to display as 52.7 %. What do I need to do to get the division
operation to round out to 4 decimal places and then display the result as a
percentage?

Any replies will be appreciated.

Joan
 
You probably have to force a conversion to floating point before doing the
division. Something like:

Result = ((Cdbl([DReceived])/Cdbl([DBooked]))

since you want a percent, just multiply by 100 as well

Result = 100 * ((Cdbl([DReceived])/Cdbl([DBooked]))

Then format that to a string with 2 decimal places:

Result = Format((100 * ((Cdbl([DReceived])/Cdbl([DBooked]))),"#.##")



--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
Pavel,
Yes. When I put Format(([DReceived]/[DBooked]), "#0.00"), Access changes
"#0.00" to Fixed and displays the result as 0.50 instead of 52.7% or .53.

Joan



Pavel Romashkin said:
Have you tried format #0.00 ?

Pavel
I have a control in the report footer where I want to divide one total in
the report footer by another total in the footer. In the report instance
that I am working with, one of the totals is 420 and the other is 797. When
I divide 420 by 797 ,( the control source is = ([DReceived]/[DBooked]).,
the result is 0.5. I'd like this result to show 4 decimal places ( For
example: .5270 ) because I would like to display this result as a
percentage in my report. . Currently, if I select "Percentage" as the
format in the control's property sheet, the result is displayed as 50.00%.
I want it to display as 52.7 %. What do I need to do to get the division
operation to round out to 4 decimal places and then display the result as a
percentage?

Any replies will be appreciated.

Joan
 
Hmm. Try placing

Format(([DReceived]/[DBooked])*100., "#0.00") & "%"

in the record source of the text box.
Pavel
Pavel,
Yes. When I put Format(([DReceived]/[DBooked]), "#0.00"), Access changes
"#0.00" to Fixed and displays the result as 0.50 instead of 52.7% or .53.

Joan

Pavel Romashkin said:
Have you tried format #0.00 ?

Pavel
I have a control in the report footer where I want to divide one total in
the report footer by another total in the footer. In the report instance
that I am working with, one of the totals is 420 and the other is 797. When
I divide 420 by 797 ,( the control source is = ([DReceived]/[DBooked]).,
the result is 0.5. I'd like this result to show 4 decimal places ( For
example: .5270 ) because I would like to display this result as a
percentage in my report. . Currently, if I select "Percentage" as the
format in the control's property sheet, the result is displayed as 50.00%.
I want it to display as 52.7 %. What do I need to do to get the division
operation to round out to 4 decimal places and then display the result as a
percentage?

Any replies will be appreciated.

Joan
 
Adrian,

Thank you. You were right! I needed to force a conversion to a floating
decimal point first, so that the result was not rounded to .50.
Thanks so much for your reply.

Joan


Adrian Jansen said:
You probably have to force a conversion to floating point before doing the
division. Something like:

Result = ((Cdbl([DReceived])/Cdbl([DBooked]))

since you want a percent, just multiply by 100 as well

Result = 100 * ((Cdbl([DReceived])/Cdbl([DBooked]))

Then format that to a string with 2 decimal places:

Result = Format((100 * ((Cdbl([DReceived])/Cdbl([DBooked]))),"#.##")



--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
Joan said:
I have a control in the report footer where I want to divide one total in
the report footer by another total in the footer. In the report instance
that I am working with, one of the totals is 420 and the other is 797. When
I divide 420 by 797 ,( the control source is = ([DReceived]/[DBooked]).,
the result is 0.5. I'd like this result to show 4 decimal places ( For
example: .5270 ) because I would like to display this result as a
percentage in my report. . Currently, if I select "Percentage" as the
format in the control's property sheet, the result is displayed as 50.00%.
I want it to display as 52.7 %. What do I need to do to get the division
operation to round out to 4 decimal places and then display the result
as
a
percentage?

Any replies will be appreciated.

Joan
 
Back
Top