Hi,
I have researched extensively on this subject on a lot of platforms. There is a lot of content out there but none seems to work for me. I'm trying to programmatically link my database (MySQL) to my FE (access 2010) but each time I get the same error "Couldn't find an installable ISAM". I have done as some forums have suggested, uninstalled and re-installed the odbc driver 3.51, set the value of the default key in the odbc driver 3.51 to null etc but still does not work. I have both 5.2 and 3.51 installed so I tried the 5.2 also, same error. I'm really stuck now...
Below is my code
I have researched extensively on this subject on a lot of platforms. There is a lot of content out there but none seems to work for me. I'm trying to programmatically link my database (MySQL) to my FE (access 2010) but each time I get the same error "Couldn't find an installable ISAM". I have done as some forums have suggested, uninstalled and re-installed the odbc driver 3.51, set the value of the default key in the odbc driver 3.51 to null etc but still does not work. I have both 5.2 and 3.51 installed so I tried the 5.2 also, same error. I'm really stuck now...
Below is my code
Code:
Private Function LinkMySQLTables() As Boolean
'DAO 3.x Required
'Declare Variables...
Dim ConnectStrg As String, rst As Recordset, _
db As Database, Strg As String
'The Connection String required to connect to MySQL.
'You will need to fill in the proper information within
'this string.
ConnectStrg = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"Server=192.168.1.7;" & _
"Port=3306;" & _
"Option=;" & _
"Stmt=;" & _
"Database=pentrust;" & _
"Uid=percy;" & _
"Pwd=Lovers1234."
'Trap any Errors...
On Error GoTo Error_LinkMySQLTables
'Open a recordset from the table the conatains
'all the table names we want to Link from the
'MySQL Database.
Set db = CurrentDb
Set rst = db.OpenRecordset("LinkedTables", dbOpenSnapshot)
With rst
'Fill the Recordset...
.MoveLast
.MoveFirst
'Enumerate through the Records...
Do Until rst.EOF
'Place the Table Name into the Strg string variable.
' FieldName (below) would be the Field name in your Access
' Table which holds the name of the MySQL Tables to Link.
Strg = !TableName
'Make sure we are not dealing will an empty string..
If Len(Strg) > 0 Then
'Link the MySQL Table to this Database.
DoCmd.TransferDatabase acLink, "ODBC Database", ConnectStrg, _
acTable, Strg, Strg
End If
'move to the next record...
.MoveNext
Loop
End With
'We're done...
Exit_LinkMySQLTables:
'Clear Variables and close the db connection.
Set rst = Nothing
If Not db Is Nothing Then db.Close
Set db = Nothing
Exit Function
Error_LinkMySQLTables:
'If there was an error then display the Error Msg.
MsgBox "Link Tables Error:" & vbCr & vbCr & _
Err.Number & " - " & Err.Description, _
vbExclamation, "Table Link Error"
Err.Clear
Resume Exit_LinkMySQLTables
End Function