Description:
Microsoft Visual Basic bug (run time error 3146, ODBCwhen using RegisterDatabase method to make a DSN, and the Silent argument = True. Silent argument = False means that the typical ODBC dialog box will pop up, True means that the dialog box will not pop up. In most apps with a Microsoft Access 2003 front end, developers will want the front end app code to make the DSN without the user knowing about it, therefore will not want the dialog box to pop up (silent argument = true).
Silent Argument = True works fine with the MySQL 3.51 driver.
Silent Argument = True does not work with the MySQL 5.1 driver.
How to repeat:
With MySQL ODBC 5.1 driver installed, and a legit MySQL database to connect to, make a Microsoft Access 2003 file and put the following into a code Module, alter the constants to suit, then run the EstablishDSN Sub:
Public Const ODBCSERVER As String = "legit_host"
Public Const LOGIN As String = "legit_login"
Public Const PASSWORD As String = "legit_password"
Public Const ODBCDATABASE As String = "legit_schema"
Public Const DSN As String = "MySQL Test DSN"
Public Sub EstablishDSN()
Dim DE As New DAO.DBEngine
DE.RegisterDatabase DSN, "MySQL ODBC 5.1 Driver", True, _
"server=" & ODBCSERVER & Chr(0) & _
"user=" & LOGIN & Chr(0) & _
"database=" & ODBCDATABASE & Chr(0) & _
"port=3306" & Chr(0) & _
"password=" & PASSWORD
Set DE = Nothing
End Sub
Suggested fix:
Fix the ODBC driver so that silent argument = True can be used and not throw a VBA bug
Description: Microsoft Visual Basic bug (run time error 3146, ODBCwhen using RegisterDatabase method to make a DSN, and the Silent argument = True. Silent argument = False means that the typical ODBC dialog box will pop up, True means that the dialog box will not pop up. In most apps with a Microsoft Access 2003 front end, developers will want the front end app code to make the DSN without the user knowing about it, therefore will not want the dialog box to pop up (silent argument = true). Silent Argument = True works fine with the MySQL 3.51 driver. Silent Argument = True does not work with the MySQL 5.1 driver. How to repeat: With MySQL ODBC 5.1 driver installed, and a legit MySQL database to connect to, make a Microsoft Access 2003 file and put the following into a code Module, alter the constants to suit, then run the EstablishDSN Sub: Public Const ODBCSERVER As String = "legit_host" Public Const LOGIN As String = "legit_login" Public Const PASSWORD As String = "legit_password" Public Const ODBCDATABASE As String = "legit_schema" Public Const DSN As String = "MySQL Test DSN" Public Sub EstablishDSN() Dim DE As New DAO.DBEngine DE.RegisterDatabase DSN, "MySQL ODBC 5.1 Driver", True, _ "server=" & ODBCSERVER & Chr(0) & _ "user=" & LOGIN & Chr(0) & _ "database=" & ODBCDATABASE & Chr(0) & _ "port=3306" & Chr(0) & _ "password=" & PASSWORD Set DE = Nothing End Sub Suggested fix: Fix the ODBC driver so that silent argument = True can be used and not throw a VBA bug