You are here:

Using MS Access/Break a number into fields for billions, millions, thousands etc in an Access 2003 report

Advertisement


Question
In an Access (2003) report I need to break a number down into five separate fields to show the value for each component part: Billions, millions, thousands, hundreds, pence.
For example the number 9,862,956.18 to
[Millions] 9
[Thousands] 862
[Hundreds] 956
[Pence] 18
I'm trying to do this with field formulas first to get the value without "punctuation" =Replace(Replace([Field1],",",""),".","")
Then a very messy iif =IIf(Len([Field1])=14,Left([Field1],3)) etc etc but without success.
Is there a better way to achieve this?

Answer
Yes, Simply divide using the INT function.

Int(number/1000000) will get you the millions

INT((number-(INT(number/1000000)*1000000))/1000) will get you the thousands

INT((number-(INT(number/1000)*1000))) will get you the hundreds

number-INT(number) will get you the pence

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Website: http://www.diamondassoc.com
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA  

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Education/Credentials
Brooklyn College BA

©2016 About.com. All rights reserved.