|
-
Nov 14th, 2006, 01:47 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Simple question ....
I got frustrated with the limitations of the Crystal Reports that came bundled with VB6 (v4 something), so I just bought CR XI Developer. I have designed several forms I wish to display from VB6 but keep running into errors when I try.
Under Project/components/designers I do have the CRXI checked. I added a new report from the project drop but did not have it placed on a discrete form. This created a CrystalReport1.dsr file which points to the correct report.
I wish for the user to press a command button on another form and have this report previewed. I'm trying the following code for that command button:
Dim CrystalReport1 As CrystalReport1
With CrystalReport1
.ReportFileName = App.Path & "\standings.rpt"
.Action = 1
End With
This results in the error "method or data member not found" for the .reportfilename. When creating the code, there is no ReportFileName in the list nor do I find .action as a possible choice either. Nothing else I've tried gets me anywhere.
How can I get VB6 to display 1 simple report? I'll worry about passing sql once I can understand how to display a report. Sigh ... always something, isn't it?
Thanks,
Ken
-
Nov 14th, 2006, 04:00 PM
#2
Re: Simple question ....
There is no need to set a file name for the designer. Basically, the Designer Form is the report file.
The Action method is from the Crystal Report OCX control. The OCX is included for backwards compatibility and it was recommended since version 8.0 to use the ActiveX control (Crystal Report Viewer Control).
When you created a new Designer Form, you were probably prompted to add another Form to the project that contains the Viewer Control. The Designer becomes the Report Source for the Viewer. The code to show the report would be something like
Dim X as New CrystalReport1
ViewerForm.ViewerControl.ReportSource = X
ViewerForm.ViewerControl.ViewReport
Personally, I never use the Designer nor do I ever "pass sql" to the report. Using the designer and inline sql statements means the Report is useless without the VB application. But then again, many of our users have Crystal - Professional Edition, which allows them to run reports without having the VB application.
-
Nov 14th, 2006, 04:38 PM
#3
Thread Starter
Addicted Member
Re: Simple question ....
Thanks Brucevde. I discovered as you said, that I need to add another form. When adding the report CRXI offers to create the form with the ocx control already done. From there it's just a case of enabling or disabling report controls on the ocx and calling the new form to show. Turned out to be simpler than I had thought.
In this case, however, I really do need to pass a sql statement to the form/report. Here's the code I'm trying (most of it was set by CRXI = mine is only the formula)
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.SearchByFormula "{Player.TeamID} = '13'"
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
This unfortunately, results in this error:
Method 'SearchByFormula" of object 'ICrystalReportViewerll' failed.
Most likely indicating an error in my syntax.
I've tried:
CRViewer1.SearchByFormula "{Player.TeamID} = 13" and
CRViewer1.SearchByFormula "{Player!TeamID} = '13'" and
CRViewer1.SearchByFormula "{Player.TeamID} = 13" but get nowhere.
The report is based on a table (Player) with the field (TeamID) as a group. I tried to simply hard code 13 into the formula to get it to work, but in reality the TeamID can be 1-255. The report DID work with CR v4.x and I'd suspect it would be compatible with v11, but perhaps not ... What would be the proper syntax? I've tried to look on the net but can't find anything different than what I've already tried.
Thanks so much,
Ken
-
Nov 14th, 2006, 05:26 PM
#4
Re: Simple question ....
I would assume the report needs to be created before you can search for a value on the report. Are you sure you want the SearchByFormula field of the CRViewer?
Regardless, try calling it after calling ViewReport. Also, try and call it with an empty string which is suppose to display the Search screen.
-
Nov 14th, 2006, 05:42 PM
#5
Thread Starter
Addicted Member
Re: Simple question ....
Thanks Brucevde. The empty search string is not allowed (not optional). It may be that I need to redo the report in XI formats and work with it that way.
I appreciate your help. Passing parameters wasn't a part of the original question so I'll mark this one resolved.
Thanks again,
Ken
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|