none
How do I look at connect property of an ODBC linked table (access 2003)

    Question

  • I defined this in code but is there any way to look at what I defined? My code is getting ODBC failure.

    Private Function ConnSQL() As Boolean
       On Error GoTo ER
       Dim db As DAO.Database
       Dim tdf As DAO.TableDef
       ConnSQL = False
       Set db = CurrentDb()
       For Each tdf In db.TableDefs
          If tdf.Name = "tblEmployees" Then
             MsgBox "Employee table already defined"
             ConnSQL = True
             Exit Function
          End If
       Next
       MsgBox "Employee table will be defined"
       Set tdf = db.CreateTableDef
       With tdf
          .Name = "tblEmployees"
          .Connect = "ODBC;Driver=SQL Server;Server=SVSQLPRD02\INSTANCE1;Database=AHCCCSPhoneDirectory;" & _
                     "Uid=AHCCCSPhoneDirectory;Pwd=AHCCCSPhoneDirectory;Trusted_Connection=No"
          .SourceTableName = "dbo.Employees"
       End With
       db.TableDefs.Append tdf
       ConnSQL = True
       Exit Function
    ER:
       MsgBox Err.Description, , "ConnSQL"
    End Function

    Wednesday, June 27, 2012 7:37 PM

Answers

All replies

  • Debug.Print tdf.Connect


    Rich P

    Wednesday, June 27, 2012 8:01 PM
  • Set a breakpoint at the top of the function, and step through carefully. See the menu options under Debug.

    Also handy to open the Locals window from the View menu.


    -Tom. Microsoft Access MVP

    Thursday, June 28, 2012 3:44 AM
  • Start the Function and hit the F8 key to step through the code, line by line, and as you go, check the values passed to the variables.

    Ryan Shuell

    Thursday, June 28, 2012 9:22 PM