Bug #48195 MySQL ODBC 5.1 driver bug with VBA, RegisterDatabase, Silent=True
Submitted: 21 Oct 2009 2:57 Modified: 6 Dec 2010 8:15
Reporter: Jordan Lun Email Updates:
Status: Verified Impact on me:
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.1.5 OS:Any
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: RegisterDatabase, silent, VBA

[21 Oct 2009 2:57] Jordan Lun
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
[21 Oct 2009 5:53] Tonci Grgin
Hi Jordan and thanks for your report.

I am sorry but even with detailed explanation from Hal in Bug#47615 I am unable to set up DAO on W2K8SE x64 so I'll assign this to Bogdan to check when time allows.
[6 Dec 2010 8:15] Bogdan Degtyariov
Verified in Connector/ODBC 5.1.8: all fields are empty in the resulting DSN