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

Changing Location of Access Database using RDC/DAO at runtime

Status
Not open for further replies.

ThatRickGuy

Programmer
Oct 12, 2001
3,841
US
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
 
Okay, figured it out, it seems that old versions of Novell (3.1 to be specific, and even 3.3 for win2k) install old versions of oleaut32.dll, olepro32.dll, and a few other files. Just thought I'd drop a line so no one else would have this same problem. so, if you can't figure it out, use the VB pakage deployer to create a Dependency file, then find them on your PC, check the versions, and compair to the user's machine. ahh well, have fun.

-Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top