Page 1 of 1

Custom Criteris Screen

Posted: Wed Feb 27, 2008 5:49 am
by jonellis
Hi,

I am trying to produce a custom criteria screen for specifying filter criteria for the report query. It needs to be dynamic and work for any report.
My idea is to read the field objects from the report & populate the first column of a 2 column grid. The user will then put the criteria in the second column.

So if my report SQL was

SELECT FieldA, FieldB, FiledC FROM MyTable

my grid would list FieldA, FieldB, FieldC in it's first column. If the user were to specify 'MyValue' in column 2 against FieldA, I would want to modify the reports underlying query to read

SELECT FieldA, FieldB, FiledC FROM MyTable WHERE FieldA = 'MyValue'

So... my questions are;

a) Can I read the field list in the report source from the report
b) Can I then change the underlying query before recompiling the report

I've looked at the components collection & played about with datasets etc, but is there a quick & easy method?

Regards,

J.

Custom Criteris Screen

Posted: Thu Feb 28, 2008 9:01 am
by Edward
a) List of the Columns in the specified "DataSourceN" you can get via the following property:

Code: Select all

report.Dictionary.DataSources["DataSourceN"].Columns
b) An underlying query of the DataSource can be changed as well:

Code: Select all

(report.Dictionary.DataSources["Categories"] as StiOleDbSource).SqlCommand = "select * from Categories where CategoryID<4";
Thank you.