Performing Calculations in a Report

  • Thread starter Thread starter Sali
  • Start date Start date
S

Sali

Hey everyone,
Is it possible to use a select statement in the control source field of an
unbound text box on a report? I have a report, the report source is a
table, but within the report, I want to use various fields from the table to
perform count calculations. So for example in an unbound text box, i would
like to count how many females/males of 5 different races were stopped for a
particular violation(speeding, seatbelt, etc). I am just wondering if it's
possible to perform this kind of calcuation in a report. Thanks in advance.
 
Sali:

No, you can't set a report's control source to a SQL statement in a report,
even for a combo box. To pull data from a table in a report using a Select
statement you must do this in code using a recordset. then Set the control
source of the text box to be equal to the value you want from the recordset.
Calcs using this type of data should also be done in code.
 
Thank you very much. That makes sense.


SA said:
Sali:

No, you can't set a report's control source to a SQL statement in a report,
even for a combo box. To pull data from a table in a report using a Select
statement you must do this in code using a recordset. then Set the control
source of the text box to be equal to the value you want from the recordset.
Calcs using this type of data should also be done in code.
 
Hey everyone,
Is it possible to use a select statement in the control source field of an
unbound text box on a report? I have a report, the report source is a
table, but within the report, I want to use various fields from the table to
perform count calculations. So for example in an unbound text box, i would
like to count how many females/males of 5 different races were stopped for a
particular violation(speeding, seatbelt, etc). I am just wondering if it's
possible to perform this kind of calcuation in a report. Thanks in advance.

You can't use a Select statement in the control source of a control.
You can use:
=Sum(IIf([Gender] = "Female" and [Race] = "Whatever" and ViolationType
= 1,1,0))
=Sum(IIf([Gender] = "Male" and [Race] = "Whatever" and [ViolationType]
= 1,1,0))
etc.
 
Back
Top