Variable/Adaptive Numeric Format

J

JASelep

in Access 2007
I some report fields that are to display quantities and amounts
the range of these numbers could be large (100,000 or $345,999) or small
(0.375 or $0.0625)
is there a way to have the field formatted to adapt to the range of the
value being displayed
for example if the value has no significant decimals then display the value
without decimal places (512.00 becomes 512) or if the value has many decimals
limit the display to only 2 decimals (0.63712938 becomes 0.64)
 
J

Jeff Boyce

How do you propose to explain to Access how to tell that a number "has no
significant decimals"? Unless you can explain it to Access, Access won't be
able to handle that.

I'm having trouble imagining a simple process that would handle integers,
real numbers, and fractional decimals. I suspect it can be done, but you'd
probably need to test each value to find out which of the above it was,
before handling appropriately.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
D

Dale Fye

If you can define the logic for "significant details", then you can use the
Detail sections Format event. Something like:

Private Sub Detail_Format

if abs(val(NZ(me.txtQuantity, 0)) - int(val(NZ(me.txtQuantity, 0)))) <
..005 Then
me.txtQuantity.Format = "#"
else
me.txtQuantity.Format = "#.00"
endif

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top