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

Crystal Reports 9, VB6 and mdb tables; How do I...

Status
Not open for further replies.

ZuperDuper

Programmer
Jun 4, 2004
39
US
I have a bit of a problem: I was given a VB6 application that has been using .rpt files v4.5 or 4.6; The program connects those files to the Access data tables. The problem is that some of the files do not work. The procedure fails on the .action property of the report: CrystalReport1.Action=1 <=does not work
I suspect that I have reports that are different versions.

To fix this I am thinking to changing all of the reports to the newer 9.0 version. We do not have older version 4.5 software anymore.
The trouble is, as I understand, that versions 8.5 and up have changed completely the way VB6 and Crystal Reports interact. I have researched tutorials from the CrystalDecisions, but I am not understanding exactly what the difference is, and what should I do to make things work.

I am new to Crystal reports, and not an expert with VB6.
How can I connect mdb to a report and display the report to the user?
This is the older version of the code:
==========================================================
With Form1.CrystalReport1
.DataFiles(0) = "c:\program files\dc analysis reports\results.mdb"
.ReportFileName = "c:\program files\dc analysis reports\proglist.rpt"
.DiscardSavedData = True

If intDestination = 0 Then
.WindowTitle = "Programmer Checklist"
.WindowState = crptMaximized
.WindowHeight = 850
.WindowWidth = 1000
.WindowTop = 0
.WindowLeft = 0
.Destination = crptToWindow
.Action = 1
ElseIf intDestination = 1 Then
.Destination = crptToPrinter
.PrintReport
End If

End With
==========================================================

Can anyone please help me or refer to a link?


 
OK, I've looked at the link and came up with this code below. I get a following error:
logonfailed
Deatails: DAO Error code: 0xbe5
Source: DAO.Workspace
Description: Could Not use 'c:\program files\dc analysis reports\cntdbfs.mdb' ; file already in use.


Dim Appn As CRAXDRT.Application, _
cReport As CRAXDRT.Report, _
strReport As String

Set Appn = CreateObject("CrystalRunTime.Application")

strReport = "c:\program files\dc analysis reports\dbfcount.rpt"
Set cReport = Appn.OpenReport(strReport)
cReport.Database.Tables(1).Location = "c:\program files\dc analysis reports\cntdbfs.mdb"
Form3.CRViewer91.ReportSource = cReport
Form3.CRViewer91.ViewReport





The error I get when using older code in post #1 is.
Error number 20225 'Unable to load report'
 
A lot of the sample apps say "for use with Crystal Reports 8.0 and higher", but that's not really an accurate statement on their (Crystal's) part.

Crystal 9 connects differently than any of the previous versions by way of Connection Properties. I suggest you have a look at this document:

Lots of useful information on how to connect to different data sources with various connection methods. In your case, if you're connecting to a secure Access database, you'd need to set the login/password information for the report before it can connect and access the database.

-dave
 
Thanks, vidru. I 've looked over the link, but I dont think this is what I need. I make the connection to the rpt file manually. See, I create my rpt files, set the databse connection to them, format it, etc., using the Crystal Reports 9 software. The report never changes after that.

I need to be able to use VB6 app and reports to populate access db, which works fine, then I need to be able to view report, and either save it or print it.

I am wondering if I am asking for the right thing here...

You should never underestimate the predictability of stupidity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top