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
Custom Criteris Screen
a) List of the Columns in the specified "DataSourceN" you can get via the following property:
b) An underlying query of the DataSource can be changed as well:
Thank you.
Code: Select all
report.Dictionary.DataSources["DataSourceN"].Columns
Code: Select all
(report.Dictionary.DataSources["Categories"] as StiOleDbSource).SqlCommand = "select * from Categories where CategoryID<4";