Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using Crystal Reports with VB6

Posted on 2004-09-13
16
Medium Priority
?
1,235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 101

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 101

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 101

Accepted Solution

by:
mlmcc earned 750 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 101

Expert Comment

by:mlmcc
ID: 12292799
Glad I could help

mlmcc
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Suggested Courses

609 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