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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with .SetDataSource when loading report in VB6 app

Status
Not open for further replies.

vbadmin

Programmer
May 11, 2004
12
US
I'm using CR9 and VB6 and want to integrate a report into my VB app so that I can create a filter in VB that will allow the user to filter out the results in the reports. When I built the report, I wrote a command query that will return all records. Then when the user selects the filter criteria, I build a new sql string based off that criteria and I want to have crystal reports run that new query on the server instead of having the server send all records to the client and then filter out the records there. In the past I've used .RecordSelectionFormula to pass the filter criteria to the report but I found out that it runs the query on the client side. So I need something that runs the query on the server side.

I tried using this code...

MyReport.Database.SetDataSource = rstTemp

rstTemp is a recordset that holds the records based off of the user's filter. When I run this and load the report, I get an error saying "<This field name is unknown.>". What's confusing is that I didn't change any of the fields selected in the new query. Any ideas what I might be doing wrong?
 
I checked out the link and I found it rather interesting that it said you can't change the command object at runtime. I have book called "The Complete Reference: Crystal Reports 9" that says you can modify it at runtime by passing the new query to the report.SQLQueryString property. But since it doesn't work for me, maybe the book is wrong. If that property is indeed read-only, you would think if you pass it a new query string, it would return some kind of an error stating that you can't modify it because it's read-only, but when I tried that, it didn't change the query or return any kind of an error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top