Results 1 to 2 of 2
  1. #1
    john.papa is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2012
    Posts
    2

    Access 03 & MySQL

    I am trying to use Access 03 as frontend and MySQL as backend in a DSNless connection. So far I have managed


    to use ADO to connect

    Code:
        Dim Conn1 As New ADODB.Connection
        Conn1.Open "DRIVER=MySQL ODBC 5.1 Driver;" & _
                       "SERVER=localhost;" & _
                       "DATABASE=sakila;" & _
                       "USER=root;" & _
                       "PASSWORD=1234;" & _
                       "OPTION=3;"
    I now need to loop through the linked tables and update the tables. I used ADOX

    Code:
      'Refresh Linked Tables
      For Each adoTbl In adoCat.Tables
        If adoTbl.Type = "PASS-THROUGH" Then
    '      adoTbl.Properties("Jet OLEDB:Link Provider String") = XXXXXXXXXX
        End If
      Next
    I can successfully loop through all linked tables, but need to assign the appropriate value to the liked table
    according to the params I used in the ADO code above.

    If I hover the cursor on any of the linked tables I receive
    "ODBC;DSN=sample-MySQL;TABLE=actor" where "sample-MySQL" = the name of the DSN
    and "actor" is the name of the table.

    Does anyone know what the linked table properties should be set to? Should it be something like
    adoTbl.Properties("Jet OLEDB:Link Provider String") = "ODBC;DSN=sample-MySQL;TABLE=" & adoTbl.Name

    Many thanks,
    John

  2. #2
    john.papa is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2012
    Posts
    2
    I believe I found a solution to my problem. The code below includes hardcoded parameters.

    Private Sub Form_Open(Cancel As Integer)
    Dim adoCat As New ADOX.Catalog
    Dim adoTbl As New ADOX.Table
    'Define attachment to FE database
    Set adoCat = New ADOX.Catalog
    Set adoCat.ActiveConnection = CurrentProject.Connection
    Set adoTbl.ParentCatalog = adoCat
    'Refresh Linked Tables
    For Each adoTbl In adoCat.Tables
    If adoTbl.Type = "PASS-THROUGH" Then
    adoTbl.Properties("Jet OLEDB:Link Provider String") = MSysObjectsConnectString
    End If
    Next
    'Clean up the connection to the database
    Set adoTbl = Nothing
    Set adoCat = Nothing
    End Sub

    Public Property Get MSysObjectsConnectString() As String
    MSysObjectsConnectString = "Driver=MySQL ODBC 5.1 Driver;Server=localhost;Database=sakila;UID=root;P WD=1234;"
    End Property

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

Similar Threads

  1. Replies: 2
    Last Post: 11-28-2011, 07:06 PM
  2. Replies: 1
    Last Post: 11-25-2011, 11:16 AM
  3. Access to SQL or MySql
    By Randy in forum Access
    Replies: 6
    Last Post: 08-05-2011, 08:38 AM
  4. MySQL & Access
    By Scorpio11 in forum Database Design
    Replies: 3
    Last Post: 05-21-2011, 02:32 PM
  5. Using Access and going to Mysql
    By fsmikwen in forum Programming
    Replies: 1
    Last Post: 11-26-2009, 01:15 PM

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