Converting and summarizing GB to MB to KB

  • Thread starter Thread starter tmg
  • Start date Start date
T

tmg

I have a database field which contains file sizes. Usually, three records
are created for each workday. These files sizes coming in may be in GB, MB
or KB. I need to convert them to KB, add them together, and them convert the
total for each day back to MB. I would prefer to convert them into a new
variable name, rather than change the initial inputted values.

I know how to create the sum for the daily group on a report, I just need
some help in converting these values and creating the new variable to be
included on the report. I'm thinking this will need some VB code.

Thanks,
 
tmg said:
I have a database field which contains file sizes. Usually, three records
are created for each workday. These files sizes coming in may be in GB, MB
or KB. I need to convert them to KB, add them together, and them convert the
total for each day back to MB. I would prefer to convert them into a new
variable name, rather than change the initial inputted values.

I know how to create the sum for the daily group on a report, I just need
some help in converting these values and creating the new variable to be
included on the report. I'm thinking this will need some VB code.


How can you tell whether the value is GB, MB or KB?
 
Gigabytes to Kilobytes = multiply by 1048576 (2 ^10)
Megabytes to Kilobytes = multiply by 1024 (2^10)

Now, you need to tell us how you determine if the stored value is GB, MB, or KB.


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
You could try the following to do the conversion

Val([TheField])*IIF([TheField] like "*GB",2^20,IIF([TheField] Like
"*MB",2^10,1))

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Interesting, the news reader seems to have converted my expression from 2
Caret Sign 20 to 2 to the twentieth.

If it happened to you I wrote
2 ^ 20 (no spaces) and 2 ^ 10 (no spaces)
as the conversion factors

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

John said:
You could try the following to do the conversion

Val([TheField])*IIF([TheField] like "*GB",2^20,IIF([TheField] Like
"*MB",2^10,1))

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
The data comes in specified as nn.nn GB or nn MB or nn KB
 
Back
Top