Solved

Using Crystal Reports with VB6

Posted on 2004-09-13
16
1,220 Views
Last Modified: 2010-08-05
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
Comment
Question by:gleznov
  • 7
  • 4
  • 3
  • +1
16 Comments
 

Author Comment

by:gleznov
ID: 12043732
Here's my third try:

    crysRep.ReportSource = "g:\supplies.rpt"
    crysRep.Refresh
0
 
LVL 7

Expert Comment

by:_agj_
ID: 12043801
0
 
LVL 7

Expert Comment

by:_agj_
ID: 12043822
  crysRep.ReportFileName = "g:\supplies.rpt"
    crysRep.Database = "g:\crmdb.mdb"
    crysRep.Action = 1
0
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.

 
LVL 7

Expert Comment

by:_agj_
ID: 12043849
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
 
LVL 2

Expert Comment

by:Lethal_J
ID: 12043938
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
 

Author Comment

by:gleznov
ID: 12044017
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
 
LVL 2

Expert Comment

by:Lethal_J
ID: 12046462
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 12051414
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
 

Author Comment

by:gleznov
ID: 12053255
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
 

Author Comment

by:gleznov
ID: 12053265
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
 

Author Comment

by:gleznov
ID: 12055161
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 12061383
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
 

Author Comment

by:gleznov
ID: 12063392
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
 

Author Comment

by:gleznov
ID: 12063834
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
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 12071610
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
 
LVL 100

Expert Comment

by:mlmcc
ID: 12292799
Glad I could help

mlmcc
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA saving file message display 5 73
Using "ScreenUpdating" 6 73
Access Object Property from VBA Module in Excel 2010 2 37
How to read File Date Created using VB6 8 52
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question