
Crystal Reports 6 and Setting MDB File Name and Location
Hi Thomas, I sent in a support request from seagate on this issue. BTW, they
were excellent on there reply and I had the answer then next day. Yes, there
is a way to change databases path/file names in the design component. I tried
their code and it works fine. The following is there reply:
Response To: Tim Hirtle
Hi Tim,
Thank you for contacting us at Seagate Software Technical
Support.The first thing I would do is check to see if
"Crystal report 6.0 ActiveX runtime library" is checked.Also make sure any
other librarys you are using in your project are referenced.
I have also included below, example code for the RDC. It shows you how to
connect to MDB file at runtime.
Dim Report As New CrystalReport1
Dim DbName As CRAXDRT.Database
Dim DbTables As CRAXDRT.DatabaseTables
Dim DbTable As CRAXDRT.DatabaseTable
Dim i As Long
Private Sub Form_Load()
'Discard saved data
Report.discardSavedData
'From the Report object , we take the current database used
'with the report and assigns it to DbName using the Database property
Set DbName = Report.Database
'From the Database object DbName, we take all the tables from the database
'used with the report and assign it to DbTables using the Tables property
Set DbTables = DbName.Tables
For i = 1 To DbTables.Count
'From the DatabaseTables object DbTables, we extract one item (the first
table)
'using the Item property (in CRW, the tables would be listed in order in
''Database|Set Location')
Set DbTable = DbTables.Item(i)
'From the DatabaseTable object DbTable, we assign the new location of the
'database for table 1 using the Location property
DbTable.Location = "c:\program files\seagate crystal reports\xtreme.mdb"
'set setsessioninfo for db table to pass your user id and password. Only do
this if you have
'security.
DbTable.SetSessionInfo "uid","pass"
Next i
'Verify the database
Report.VerifyOnEveryPrint
'crystal automatically places these on the form.
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Distroy the report object this will free up memory
Set report= nothing
End Sub
Reguards
Garrett
Seagate Software IMG
Quote:
> This works with Crystal Reports 6 but not with the Crystal Reports 6
> Designer component for VB5. The designer does not support the .datafiles()
> I now wonder if there is any method of changing the database in the Crystal
> reports 6 Designer (the free download version). Or is this component
> crippled and of no use in real-world applications? Maybe this is why it is
> free?