VB 6 and Crystal Reports Designer dao path problem

I have created some reports in my project using the Crystal Reports Designer. When I created them I used the dao method and picked the database that I wanted to use. Well now I have my reports done but my project has hard coded paths. I have looked everywhere for a solution including Seagates knowledge base. I must be a big dummy because no matter what I try I cant get it to work.
 What I need is a way to tell my report. "Your data comes from" App.Path & "\MyDatabase.mdb". At the moment it looks for it in "C:\MyFolder\MyDatabase.mdb".
BigwayAsked:
Who is Participating?
 
ramaswamy_raviConnect With a Mentor Commented:
Bigway,

Set the data files property as

CrystalReport1.DataFiles(0) = "C:\New Folder\Database.mdb"

Should your report use more than one database, the sequence of the tables should be the same as used at design-time.

You can get the sequence by going to Database/Set Location in the design mode.
0
 
BigwayAuthor Commented:
Oh yes. Am I stupid or just using Crystal Reports in a way that it should not be. It does not seem to me that this sort of a thing, given that you dont want hard coded paths, should be such a big deal to fix.
0
 
magoo2Commented:
Bigway

you can tell the report where the database is and which way to select data from it.

First you create the project as you did , and then give the path in the in the codebox of the viewer form.

This is an example which uses an integer that is used in select case to decide which way to use the data. - gDataBaseName is a global variable holding the path and name of the Access database

setting up the project I selected all the data I needed with sql query instead of table
this is code for frmShowPayments1 & the designer object name is ShowPayments1 Showchecks is the integer variable
**************************************

Dim Report As New ShowPayments1

Option Explicit

Private Sub Form_Load()
Dim rs As New ADOR.Recordset
Dim astring As String
Dim bstring As String

Select Case ShowChecks
 Case 0
   astring = "SELECT Payments.LotNumber, Payments.Recieved, Payments.AmountPaid FROM Payments"

 Case 1
   astring = "SELECT  Payments.CheckNumber, Owners.OwnerID, Owners.Prefix, Owners.FirstName, Owners.LastName FROM Payments, Owners WHERE Owners.OwnerID = Payments.OwnerID"
 
 Case 2
  astring = "SELECT Payments.LotNumber, Payments.Recieved, Owners.FirstName, Owners.LastName, Owners.Affix FROM Payments"
 

 Case Else
  Unload Me
 End Select

bstring = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & gDataBaseName


rs.Open astring, bstring, adOpenKeyset


Report.Database.SetDataSource rs

CRViewer1.ReportSource = Report
CRViewer1.ViewReport

End Sub


hope this helps

magoo
0
 
BigwayAuthor Commented:
Ill give that a try and see if it works, if it does of course ill give you the points. What I did do while I was waiting for an answer was start to creat new reports using Ado instead of Dao. I was easily able to modify it for the path problem. Do you think that I should just use the Ado instead of Dao. What would you use?
0
 
ramaswamy_raviCommented:
Bigway I created the test report using data files and not using ADO or DAO. I know you are not using this approach in any case.

Ravi

0
All Courses

From novice to tech pro — start learning today.