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".
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

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

End Sub

hope this helps


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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
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.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.