Calculated fields on reports

G

Guest

I have a calculcated field on a form that converts a quantity from metric to
eng if another field on the from is a specified number for various records.
On the form it works great. However, when I use the same code for the
report, it converts all of the records to the same amount. For example: One
record (elemkey 301) is 11159 meters sq and another (elemkey 12) is 289
linear meters. The system sees the elemkey 301 and converts 11159 to square
feet correctly, but it puts the same value for the record elemkey 12, with
289 linear feet. Below is a sample of the code I am using. It appears the
report does not realize there are multiple records and should calculate each
one separatly.

Option Compare Database
Private Sub report_Activate()
Select Case Report_Query2reportsubreport.ELEMKEY
Case "301"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "302"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "303"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "304"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "399"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "12"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
Case "38"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
Case "98"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
Case "13"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
 
M

Marshall Barton

mdbbkm said:
I have a calculcated field on a form that converts a quantity from metric to
eng if another field on the from is a specified number for various records.
On the form it works great. However, when I use the same code for the
report, it converts all of the records to the same amount. For example: One
record (elemkey 301) is 11159 meters sq and another (elemkey 12) is 289
linear meters. The system sees the elemkey 301 and converts 11159 to square
feet correctly, but it puts the same value for the record elemkey 12, with
289 linear feet. Below is a sample of the code I am using. It appears the
report does not realize there are multiple records and should calculate each
one separatly.

Option Compare Database
Private Sub report_Activate()
Select Case Report_Query2reportsubreport.ELEMKEY
Case "301"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "302"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "303"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "304"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "399"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.305
Case "12"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
Case "38"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
Case "98"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929
Case "13"
Report_Query2reportsubreport.Label27.Caption = QUANTITY / 0.0929


Don't use the Activate event, it's only triggers when the
report is opened in previrew mode.

Put your code in the Format event of the section containing
the labels and QUANTITY value.
 

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