ThatRickGuy
Programmer
Hey Everyone, I've been beating my head against a brick wall on this one. The program is a VB 6 app that connects to a Access 2000 database, using the RDC and crViewer. I use a native DAO connection to the database. Problem is, the users all have different computers so it needs to be able to use the database dynamicly. I store the path to the DB in an INI file and read it in on program start. I have no problems in the VB portion, but when the user tries to get a print preview (loads the form w/ crViewer) I get the following error: "Error opening file. File could not be opened: "dao", at file location: "main"
dao is the default name CR gives the DB as you creat the report in the designer. Main is the name of the table I'm trying to access. here is the code:
'DBName is global and contains the path
'and name of the access database
Dim Report As Craxdrt.Report
Dim crxTables As Craxdrt.DatabaseTables
Dim crxTable As Craxdrt.DatabaseTable
Dim crxSections As Craxdrt.Sections
Dim crxSection As Craxdrt.Section
Dim crxSubReportObj As Craxdrt.SubreportObject
Dim crxReportObjs As Craxdrt.ReportObjects
Dim crxSubReport As Craxdrt.Report
Dim ReportObject As Object
Private Sub Form_Load()
Dim rsReport As DAO.Recordset
Set Report = crIntOrders
'set the recordset
Set rsReport = DB.OpenRecordset("SELECT * FROM Main WHERE Exported=False AND AccountInfoStore=False"
'this section sets the DB location for
'the subreports. all of them appear to load up
'fine, .testconnectivity returns 'true'
Set crxSections = Report.Sections
For Each crxSection In crxSections
Set crxReportObjs = crxSection.ReportObjects
For Each ReportObject In crxReportObjs
If ReportObject.Kind = crSubreportObject Then
Set crxSubReportObj = ReportObject
Set crxSubReport = crxSubReportObj.OpenSubreport
Set crxTables = crxSubReport.Database.Tables
Set crxTable = crxTables.Item(1)
crxTable.SetDataSource rsReport, 3
crxTable.Location = DBName
End If
Next ReportObject
Next crxSection
'this is where I have problems
With Report.Database.Tables(1)
.SetDataSource rsReport, 3
.Location = DBName
MsgBox "Location: " & .Location & Chr(13) & _
"Name: " & .Name & Chr(13) & _
"Test Connection: " & .TestConnectivity
End With
the message box returns the correct location of the installed data base, the name 'dao', testconnection is false. After the message box I get "Open database session failed" Anyideas? I changed the diming of the report from "dim report as new crIntOrders" after reading some stuff on crystal's knowledge base about a bug with access.
ahh well, any help would be greatly appreciated!
-Rick
dao is the default name CR gives the DB as you creat the report in the designer. Main is the name of the table I'm trying to access. here is the code:
'DBName is global and contains the path
'and name of the access database
Dim Report As Craxdrt.Report
Dim crxTables As Craxdrt.DatabaseTables
Dim crxTable As Craxdrt.DatabaseTable
Dim crxSections As Craxdrt.Sections
Dim crxSection As Craxdrt.Section
Dim crxSubReportObj As Craxdrt.SubreportObject
Dim crxReportObjs As Craxdrt.ReportObjects
Dim crxSubReport As Craxdrt.Report
Dim ReportObject As Object
Private Sub Form_Load()
Dim rsReport As DAO.Recordset
Set Report = crIntOrders
'set the recordset
Set rsReport = DB.OpenRecordset("SELECT * FROM Main WHERE Exported=False AND AccountInfoStore=False"
'this section sets the DB location for
'the subreports. all of them appear to load up
'fine, .testconnectivity returns 'true'
Set crxSections = Report.Sections
For Each crxSection In crxSections
Set crxReportObjs = crxSection.ReportObjects
For Each ReportObject In crxReportObjs
If ReportObject.Kind = crSubreportObject Then
Set crxSubReportObj = ReportObject
Set crxSubReport = crxSubReportObj.OpenSubreport
Set crxTables = crxSubReport.Database.Tables
Set crxTable = crxTables.Item(1)
crxTable.SetDataSource rsReport, 3
crxTable.Location = DBName
End If
Next ReportObject
Next crxSection
'this is where I have problems
With Report.Database.Tables(1)
.SetDataSource rsReport, 3
.Location = DBName
MsgBox "Location: " & .Location & Chr(13) & _
"Name: " & .Name & Chr(13) & _
"Test Connection: " & .TestConnectivity
End With
the message box returns the correct location of the installed data base, the name 'dao', testconnection is false. After the message box I get "Open database session failed" Anyideas? I changed the diming of the report from "dim report as new crIntOrders" after reading some stuff on crystal's knowledge base about a bug with access.
ahh well, any help would be greatly appreciated!
-Rick