I'm fighting with a VBA non-interactive problem that really bugs me: I have a pass-through query to a mysql database, which works well if double-clicked by the user. But it fails if called from VBA automation session (called from excel) if no interaction was done first. Most strange: it works from VBA after clicking it on the GUI for a while (odbc mysql connection timeout possibly).
The passthrough-query has it's password in the DSN and in the connection string (to sort out problems with the store). The behavior is the same with a linked table.
Problematic VBA code called looks like this:
CurrentProject.Connection.Execute "INSERT INTO [SomeLocalTable] (id) SELECT id FROM [somePassThroughOrLinkedMySQLTable]"
The error is a generic odbc connection failure 80004005.
While this type of query works all the time:
Dim cnn As New ADODB.Connection
cnn.Open ("Driver=MySQL ODBC 5.2w Driver;SERVER=myserver;UID=user;DATABASE={db};PORT=3306;DFLT_BIGINT_BIND_STR=1;PWD=secret")
Can I "initialize" the passthrough query like the UI does to make it work? Or can I use the second type of query to insert into a local MS Access table?
Environment: Win8-64bit, Office2013, mysql-odbc-5.2w