Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Filtered Reports

Status
Not open for further replies.

ntp

Programmer
Jan 28, 2001
22
TT
I'm creating a front end to a MS Access DB linked to a Ctree++ Db using VB. I want to create a report based on some selections the user checks on a form. For example the user selects the various types of services to be reported for and the report is supposed to show all the vendors who offer such service, grouped by service. All the data is comming from the Access Db. I used Report designer to create a command and then used that as the datasource of the report. When the user makes a selection I create a Where clause that is inserted into the CommandText value for the command. The report works fine for the selections filtering but only works the first time. I close the report and then open and enter different options but only the options selected the first time are used. Only if I close the entire app down the restart does it allow me modify the SQL behind the Command. I tried the parameter option for the command but the thing is I do not know how many parameters will be specified by the user (between zero and thirty max). Do I have to close some connection or is it persistent somehow? I read in a previous post about using an ADO recordset to be the source of the report but I am getting problems with that in specifying the relation between controls on the form and field in the recordset. Can anyone tell me how to do this (creating a report based on runtime where-clause options)? Maybe there is a simpler method that I am not seeing. I am fairly new at this.

Navin Parray
 
Could you send me your code. I will see if I can be any help to you. My e-mail address is ravinuthala@un.org
 
Thanks for the interset but I solved the problem myself. It seems I was supposed to load the DataEnviroment object then test the state of the recordset i was trying to update and if it was open I needed to close it. Then I updated the SQL and refreshed the report object.

The code I used was something like

Load DataEnvironment1
If DataEnvironment1.rsSomeRecordset.state <> 0 then
DataEnvironment1.rsSomeRecordset.close
End if
DataEnvironment1.rsSomeRecordset.commandText = strNewSQL
DataReport1.Refresh
DataReport1.Show

Navin Parray
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top