Results 1 to 4 of 4

Thread: [RESOLVED] Edit Link table connection string in Access

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    48

    [RESOLVED] Edit Link table connection string in Access

    Right i can open a dialog to select the file to link to, and i can read the connection string for the table, but i can't get the string to be altered!

    Code looks like this:

    VB Code:
    1. Private Sub Command0_Click()
    2.    
    3.     'Opens the dialog
    4.     RelinkFile
    5.     ' Old Connect String
    6.     Text1.Value = CurrentDb.TableDefs("stafflist").Connect
    7.     ' Change connect string
    8.     CurrentDb.TableDefs("staffList").Connect = "Excel 5.0;HDR=YES;IMEX=2;DATABASE=" & sFile
    9.     ' Out put the 'new' connect string
    10.     Text1.Value = CurrentDb.TableDefs("staffList").Connect
    11.     ' Check the dialog actually collected the file name/path
    12.     Text6.Value = sFile
    13.    
    14. End Sub
    Last edited by c03cg; Jul 14th, 2006 at 03:02 AM.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Edit Link table connection string in Access

    wow.. couldnt get it to work either... odd.. it says you can set or read the value..


    but.. if you are changing the source.. then why not dump the table and re-link

    VB Code:
    1. DoCmd.DeleteObject acTable, "Test"
    2. Application.RefreshDatabaseWindow
    3. DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "Test", "C:\path\to\file.xls"
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    48

    Re: Edit Link table connection string in Access

    Coolies... ill have a go at that..... was really scratching my head over it!!

    [EDIT...]

    That works, but i also need to use the first set of entries as column headings.....
    Last edited by c03cg; Jul 14th, 2006 at 02:56 AM.

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    48

    Re: Edit Link table connection string in Access

    Got it!

    added TRUE as the 'Has Field Names' property to make:

    VB Code:
    1. DoCmd.TransferSpreadsheet acLink, 8, "staffList", sFile, True

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width