I am getting an erro on line 11, OpenDatabase(Na me As String, [Options], [ReadOnly], [Connect]) I can leave the Options field blank, and it errors saying that the password is invalid, I am 100% certian that the password is correct, and if I leave it blank it prompts then errors. I have read countless articles, and reregistered the DLL's and even reinstalled office, to no avail. Anyone with any ideas that would be excellent.
Code:
Public Function fnReadDBTables(FilePath As String, Pword As String, SavePath As String)
Dim dbname As String
Dim rst2 As DAO.Recordset
Dim DbRead As DAO.Database
Dim mySQL1 As DAO.Recordset
Dim filetemp1 As Integer 'start of file string
Dim filetemp2 As Integer 'end of file string
dbname = Forms![main]![dbNameComboBox1]
Set DbRead = DAO.OpenDatabase(FilePath, False, False, Pword)
Set rst2 = db.OpenRecordset("tblDatabaseTables", dbOpenDynaset)
Set mySQL1 = DbRead.OpenRecordset(("SELECT MSysObjects.Name, MSysObjects.Database, _
MSysObjects.Connect, MSysObjects.Type _
FROM MSysObjects WHERE (((MSysObjects.Name) Not Like ('MSys*') And _
(MSysObjects.Name) Not Like ('~TMPCLP*')) AND _
((MSysObjects.Type)=1 Or (MSysObjects.Type)=6)) ORDER BY MSysObjects.Name;"))
Do Until mySQL1.EOF
rst2.AddNew
rst2("DatabaseName") = dbname
rst2("TableName") = mySQL1!Name
rst2("Database") = mySQL1!Database
If Not mySQL1!Database = "" Then
filetemp1 = InStrRev(mySQL1!Database, "\")
filetemp2 = InStrRev(mySQL1!Database, ".")
Else
filetemp1 = 1
filetemp2 = 0
End If
If filetemp2 > filetemp1 Then
rst2("DatabaseName2") = Mid(mySQL1!Database, _
(filetemp1 + 1), ((filetemp2 + 3) - filetemp1))
Else
rst2("DatabaseName2") = ""
End If
rst2("Connect") = mySQL1!Connect
rst2("Type") = mySQL1!Type
rst2.Update
mySQL1.MoveNext
Loop
Set rst2 = Nothing
DbRead.Close
End Function
Comment