Results 1 to 4 of 4
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    There are several tables with that name

    Hi i am trying to refresh link but method below is failed:



    Code:
    Function RemoveAndConnectToOdbcTables()
    
    
    Dim username, pass, strConnect, strConnectQuery As String
    Dim i As Long
    
    
    username = Environ("username")
    pass = "PasswordAccess"
    
    
    '''You can use a pass-through query to list the table names from your SQL Server database. Open a recordset based on that query. Then loop through the recordset rows and link each table.
    On Error GoTo ErroHandler
    
    
    username = "admin"
    pass = "PasswordAccess"
    
    
    strConnect = "ODBC;DRIVER={PostgreSQL Unicode};" & _
    "DATABASE=AccessLog;" & _
    "SERVER=localhost;" & _
    "PORT=5432;" & _
    "UID=" & username & ";" & _
    "PWD=" & pass & ";" & _
    "Trusted_Connection=Yes;"
    
    
    strConnectQuery = "ODBC;DRIVER={PostgreSQL Unicode};" & _
    "DATABASE=AccessLog;" & _
    "SERVER=localhost;" & _
    "PORT=5432;" & _
    "UID=" & username & ";" & _
    "PWD=" & pass & ";" & _
    "Trusted_Connection=Yes;"
    
    
     DoCmd.Hourglass True
        Dim db As DAO.Database
        Dim tdef As TableDef
        Dim qdef As QueryDef
        Dim missingTbl() As String
        Dim upper As Integer
        Dim strMsg As String
        Dim tdfCurrent As TableDef
        Dim TableName As String
        
        Set db = CurrentDb
        For i = 0 To CurrentDb.TableDefs.Count - 1
            Set tdef = db.TableDefs(i)
            Debug.Print tdef.Name
            TableName = tdef.Name
      ''          If Len(tdef.Connect) > 0 And Left(tdef.Name, 1) = "t" Then
                If Not (tdef.Name Like "MSys*" Or tdef.Name Like "~*") Then
                    DoCmd.DeleteObject acTable, tdef.Name
                    Set tdfCurrent = db.CreateTableDef(tdef.Name)
                    tdfCurrent.Connect = strConnect
                    tdfCurrent.SourceTableName = tdef.Name
                    db.TableDefs.Append tdfCurrent
    
    
                    db.TableDefs(TableName).RefreshLink
                End If
        Next i
    
    
        For Each qdef In CurrentDb.QueryDefs
        Debug.Print qdef.Name
            If qdef.Type = dbQSQLPassThrough Then
                qdef.Connect = strConnect
            End If
        Next qdef
        
        DoCmd.Hourglass False
        
    Exit Function
    
    
    ErroHandler:
    MsgBox "Error number is: " & Err.Number & "; " & Err.Description
    DoCmd.Hourglass False
    
    
    End Function
    error is:

    https://www.google.pl/search?q=there...hrome&ie=UTF-8

    but i do not understand this,
    can anyone help?

    Best,
    Jacek

  2. #2
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Anyone?

    Jacek

  3. #3
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Nobody is removing linked table and access them using DNS-less connection?

    Best,
    Jacek

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Hi Jacek,

    I do but with SQL server, so I'm not sure the methods I use are the same.
    The definitive guide is here http://www.accessmvp.com/djsteele/DSNLessLinks.html
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 6
    Last Post: 04-18-2018, 06:56 AM
  2. Replies: 17
    Last Post: 04-09-2018, 04:39 PM
  3. Replies: 2
    Last Post: 07-15-2014, 10:39 AM
  4. Replies: 1
    Last Post: 12-11-2013, 01:18 PM
  5. Replies: 4
    Last Post: 11-22-2013, 11:20 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