Performing Calculations in a Report

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.
 
S

SA

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.
 
S

Sali

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.
 
F

fredg

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.
 

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