Hello.
I use MySQL as a database.
I connected the database using ODBC Administrator.
However, I found this to be a security problem.
When someone connects to this ODBC, all database information can be viewed and modified.
Therefore, I found that I need to connect to VBA automatically without using ODBC Administrator.
I found the following code:
This shows the following error in ".TableDefs.Append tdf".
error message : Could not find installable ISAM file.
Private Function LinkTable()
Dim tdf As New DAO.TableDef
With CurrentDb
.TableDefs.Refresh
Set tdf = .CreateTableDef("tablename")
tdf.Connect = "Driver={MySQL ODBC 8.0 Unicode Driver};Server=xxx.xxx.xxx.xxx;Port=3306;Database=database;User=username;Password=pass;"
tdf.SourceTableName = "tablename"
.TableDefs.Append tdf
.TableDefs.Refresh
End With
Set tdf = Nothing
End Function
There is also an expected problem.
When opening the first access file, you should run the connection logic first.
Please show the complete code including this problem.
Thank you.
I use MySQL as a database.
I connected the database using ODBC Administrator.
However, I found this to be a security problem.
When someone connects to this ODBC, all database information can be viewed and modified.
Therefore, I found that I need to connect to VBA automatically without using ODBC Administrator.
I found the following code:
This shows the following error in ".TableDefs.Append tdf".
error message : Could not find installable ISAM file.
Private Function LinkTable()
Dim tdf As New DAO.TableDef
With CurrentDb
.TableDefs.Refresh
Set tdf = .CreateTableDef("tablename")
tdf.Connect = "Driver={MySQL ODBC 8.0 Unicode Driver};Server=xxx.xxx.xxx.xxx;Port=3306;Database=database;User=username;Password=pass;"
tdf.SourceTableName = "tablename"
.TableDefs.Append tdf
.TableDefs.Refresh
End With
Set tdf = Nothing
End Function
There is also an expected problem.
When opening the first access file, you should run the connection logic first.
Please show the complete code including this problem.
Thank you.