Results 1 to 4 of 4
  1. #1
    lvman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    3

    Wink How can I use VBA for ODBC connection to MySQL data source?

    How can I use VBA for ODBC connection to MySQL data source?
    My company has two MySQL servers. One is for development, and the other is for production. I created an Access application, say MyAcc. MyAcc is connected to MySQL servers through ODBC connection. The connection was made through SSL (Secure Sockets Layer). To activate MyAcc I click “External Data” in the Rainbow, choose “ODBC Database”. Then in the popup window “Get External Data – ODBC Database”, choose “Link to the data source…” another popup window “Select Data Source” appears. There are two tabs, I choose “Machine Data Source”, then choose data source, say, abc-mysql-dev (under the column “Data Source Name” ). A list shows up, and I could choose whichever tables I need from the list.


    There is also a data source for production, say, abc-mysql-prod
    My question is: How can I use VBA code to link tables in one of 2 data sources: abc-mysql-development and abc-mysql-prod?
    The reason for having VBA coding instead of manually set linking tables is that I could add an option control, or a combo box to let users choose product environment or developing environment. The later can be used for testing code or training.
    I tried the code line
    DoCmd.TransferDatabase acLink, "ODBC Database", "ODBC;DSN='abc-mysql-dev';UID=;PWD=;LANGUAGE=;DATABASE=", acTable, "tOrder", "tOrder"
    But it failed.
    Can someone show me the right way to connect MySQL data source in VBA coding?
    Your help will be highly appreciated.

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I haven't done this for a while, but I think you may need Opendatabase

    instead of transferdatabase.
    Check out this link:
    http://msdn.microsoft.com/en-us/libr...ice.12%29.aspx

  3. #3
    lvman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    3

    The link that you provided looks very useful

    The link that you provided looks very useful. I will try it soon, and let you know if the issue is resolved. Thank you very much!

  4. #4
    lvman is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2011
    Posts
    3

    The issue is resolved. Thanks for the help

    The issue is resolved. Thanks for the help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-15-2011, 07:26 AM
  2. Replies: 5
    Last Post: 10-25-2011, 08:01 AM
  3. ODBC connection
    By avicenna in forum Import/Export Data
    Replies: 2
    Last Post: 08-02-2010, 02:33 AM
  4. Access data page connection to MySQL
    By dkperez in forum Access
    Replies: 1
    Last Post: 09-29-2009, 06:02 AM
  5. Replies: 0
    Last Post: 08-30-2006, 02:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums