Using CR 126.96.36.199 with VB 6
Posted on 2003-03-23
I am developing an application in VB with Access backend.
I need to generate reports based on the outputs of the datacontrol in the form. The .DataSource for the datacontrol changes every time since it does varied search on the database tables.
I have designed a format of the report in Crystal Report 4.6.1 with all the required fields and named it "searchreport1.rpt".
And I have added the Crystal Reports control to the Result-display-form
I also have provided a button on the form which can be used to get the reports printed.
The .RptFileName has been set to the .rpt file as well.
The .ReportSource has been set to 3-crptDataControl.
How can I set the Datasource property of the CR Control to the datacontrol(machinedatasearch) on clicking the "Print Report" button on the form?.I need to do this since there are 2 datacontrols in the form.
I have already tried
rpt1.DataSource = machinedatasearch
When I give the rpt1.Action = 1 , I do get the correct results printed.But they are not in the required format.
When the .ReportSource property of the CR control is set to the datacontrol,I seem to get the correct results but in the wrong format,ie, all the fields in the table are printed and there is not formatting whatsoever.
When the .ReportSource is set to the Report,I get the wrong results,ie all the records in the table gets printed without any filtering,but I do get the correct format.I had set some font formatting and bordering in the .rpt file.All these things get printed nice and fine.
Please give the details as I don't have much idea about how to use the CR to generate reports dynamically.