Rounding up and down

saintsman

Registered User.
Local time
Today, 00:27
Joined
Oct 12, 2001
Messages
138
I have a form with a field that gives me an average of results. Below the number 10 it works fine - for example, if I have 6.3 as an average it displays 6, if it is 6.7 it displays 7.

If however the number is greater than 10 I have a problem. Should the number contain a decimal it rounds down to 10 or up to 20. ie any number below 14.9 will round down to 10 and any number above 15.1 will round up to 20. Whole numbers display fine.

Any ideas?
 
I have just Tried the following with a variety of numbers and it works fine.

txtAns = Round(txtRnd1)


Please could you post more information, like the code you are using!
 
Last edited:
Uncle Gizmo,

Thank you for your reply. It took me a while but I've just found the answer myself.

The average result was a single field on a form and then used as a sub form in my main form.

The field in the original form was about 1.5cm square with a font size of 24. I had set the decimal places property to 0 so I expected it to round up and display the whole value I wanted. However it didn't do that. It displayed the decimal as well but because the size of the box wasn't big enough for the numbers and the decimal, it rounded it to either 10 or 20. Making the box bigger allowed the real value to be shown.

What I should have done was when I set the decimal places to 0, I should have also set the format to 'fixed'. Box size has now been returned to its original size and it works fine.

Sometimes the smallest mistake takes a long time to fix!

Regards,

Saintsman
 
Uncle Gizmo,

Thank you for your reply. It took me a while but I've just found the answer myself.

The average result was a single field on a form and then used as a sub form in my main form.

The field in the original form was about 1.5cm square with a font size of 24. I had set the decimal places property to 0 so I expected it to round up and display the whole value I wanted. However it didn't do that. It displayed the decimal as well but because the size of the box wasn't big enough for the numbers and the decimal, it rounded it to either 10 or 20. Making the box bigger allowed the real value to be shown.

What I should have done was when I set the decimal places to 0, I should have also set the format to 'fixed'. Box size has now been returned to its original size and it works fine.

Sometimes the smallest mistake takes a long time to fix!

Regards,

Saintsman
 
Uncle Gizmo,

Thank you for your reply. It took me a while but I've just found the answer myself.

The average result was a single field on a form and then used as a sub form in my main form.

The field in the original form was about 1.5cm square with a font size of 24. I had set the decimal places property to 0 so I expected it to round up and display the whole value I wanted. However it didn't do that. It displayed the decimal as well but because the size of the box wasn't big enough for the numbers and the decimal, it rounded it to either 10 or 20. Making the box bigger allowed the real value to be shown.

What I should have done was when I set the decimal places to 0, I should have also set the format to 'fixed'. Box size has now been returned to its original size and it works fine.

Sometimes the smallest mistake takes a long time to fix!

Regards,

Saintsman
 

Users who are viewing this thread

Back
Top Bottom