• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1244
  • Last Modified:

Using Crystal Reports with VB6

Hi,

     I've been programming applications using Crystal Reports in VB.NET for several weeks now.  Our inventory system is written in VB6 though, so now I need to incorporate some reports into that application.  I installed the disc 3 crystal reports, added the component and placed the report on my form (name: crysRep) - but I don't know how to open the report with it or pass a selectionformula.  Here's what I've got:

' Attempt 1:
    'CrystalActiveXReportViewer1.ReportSource = "g:\supplies.rpt"
    'CrystalActiveXReportViewer1.SearchByFormula = "{supplies_trans.trans_type}='dispense'"
    'CrystalActiveXReportViewer1.Refresh
   
' Attempt 2:
    crysRep.ReportFileName = "g:\supplies.rpt"
    'crysRep.Datafiles(0) = "g:\crmdb.mdb"
    'crysRep.Destination = crptToWindow
    crysRep.Action = 1


Neither of these are working - I'm just not sure what the methods are to set the report page to a .rpt file and then to pass a formula to it.

JP
0
gleznov
Asked:
gleznov
  • 7
  • 4
  • 3
  • +1
1 Solution
 
gleznovAuthor Commented:
Here's my third try:

    crysRep.ReportSource = "g:\supplies.rpt"
    crysRep.Refresh
0
 
_agj_Commented:
  crysRep.ReportFileName = "g:\supplies.rpt"
    crysRep.Database = "g:\crmdb.mdb"
    crysRep.Action = 1
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
_agj_Commented:
dont know which version u are using.

earllier versions had:

CrystalReport1.Destination = 0
CrystalReport1.PrintReport ' for displaying

if u are using vb u wud just get the object structure shown automatically....shudnt be much confusion
0
 
Lethal_JCommented:
crReport.SelectionFormula = "{tblTable.fldField} = 10"
crReport.Destination = (This should drop down a list of destinations, i.e: Printer, Window, etc)
crReport.PrintReport (This will execute the report and deliver it to the 'Destination')

You can also set up variables on the report and pass values to them.  More details here:  http://visualbasic.ittoolbox.com/documents/document.asp?i=2656
0
 
gleznovAuthor Commented:
I may be using the wrong component or something - as I mentioned, I've been using .NET.  I've also got Crystal Reports 10.  The component I'm using is:

Crystal ActiveX Report Viewer Library 10.0

There are no Database, ReportFileName, or Action methods.  There's a ReportSource, but I see nothing for selectionformula either...  What should I be using?

JP
0
 
Lethal_JCommented:
Im using Crystal 6, and in my version i use "Crystal Report Control".  There is another also called "Crystal Report Design-time Control" however that is for adding report building functions to the application.

Im unsure what the control may be called in Crystal 10, however if you feel you are using the wrong control then look to see if there is any other Crystal control in the components.

Good luck with the project
0
 
mlmccCommented:
I think you may have a mix of Crystal versions.  Crystal.Net is based on CR9 so the CR10 viewer may not work.

There are other dlls you may need also.  What edition of Crystal 10?  Did you install Crystal from the Studio.Net cds?

mlmcc
0
 
gleznovAuthor Commented:
Let me restate in case I caused any confusion that I've been using .NET successfully, now I'm trying to use CR in VB6...

JP
0
 
gleznovAuthor Commented:
I did install Crystal (I think 4.5 or something?) from the third CD in the Visual Studio set.  Crystal 10 controls are available, but I'm not sure if they're really compatible with VB6 - I don't see any Crystal components that don't say 10, although I installed it from that third CD.

JP
0
 
gleznovAuthor Commented:
I've found a Crystal Reports 4.5 component, but it doesn't seem to be a report - it's an icon that I can't stretch over the form, but it does have the reportfile, etc properties...  I'm guessing I just don't know how to code it - the code listed above gave me an error: Unable to Load Report

   
    crysRep.ReportFileName = "g:\supplies.rpt"
    crysRep.DataFiles(0) = "g:\crmdb.mdb"
    crysRep.Destination = crptToWindow
    crysRep.Action = 1
   
The report is supplies.rpt in the g:\ directory - the database that it accesses is an access database in g:\ called crmdb.mdb

What's up?

JP
0
 
mlmccCommented:
The Crystal 10 controls probably cannot read the CR4.6 files.

The Crystal 10 controls are compatible with VB6 just not with CR4.6.

What version of Crystal was the supplies.rpt report developed?

mlmcc
0
 
gleznovAuthor Commented:
supplies.rpt was done with CR10 - should I completely uninstall 4.6 then?  I figured I needed to use the 4.6 in the VB so I wouldn't have any licensing problems.

JP
0
 
gleznovAuthor Commented:
I've tried referencing as much CR stuff as I think could possibly be necessary, and then component-ing just as many.  I still only come up with:

a 4.6 control that looks like an icon - it has reportfile property and such, but doesn't seem to display anything, and
a 10 control that looks like a crystal report - I can drag it to cover a larger area, but it has no reportsource properties or anything like that.

Anybody know what exactly I need to reference or component-ize to get this combo working?

JP
0
 
mlmccCommented:
The report format has changed several times between CR4.6 and CR10.  CR4.6 can only be used with CR4.6 reports.

You can leave it installed if you want but it may cause problems with CR10 and VB so I recommend you uninstall it.

Which edition of CR10 do you have?  If it is the Advanced edition I would unistall CR4.6, uninstall CR10, reboot, the reinstall CR10 ensuring you install the VB files from CR10.

mlmcc
0
 
mlmccCommented:
Glad I could help

mlmcc
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now