dbTalk Databases Forums  

Check links to .xls file

comp.databases.ms-access comp.databases.ms-access


Discuss Check links to .xls file in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jim Baird
 
Posts: n/a

Default Check links to .xls file - 08-04-2012 , 10:40 AM






I have a routine to check linkage to back end of a database and relink to it on opening of the application. In new application I have a number of spreadsheets that I have to insure are linked and am not sure how to amend the following code to search for these files.

Private Function RefreshLinks(strFileName As String) As Boolean
' Refresh links to the supplied Spreadsheet. Return True if successful.

Dim dbs As Database
Dim tdf As TableDef

' Loop through all tables in the Spreadsheet.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
' If the table has a connect string, it's a linked table.
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & strFileName
Err = 0
On Error Resume Next
tdf.RefreshLink ' Relink the table.
If Err <> 0 Then
RefreshLinks = False
Exit Function
End If
End If
Next tdf
RefreshLinks = True ' Relinking complete.

End Function

Hopefully answer to this question will be strong clue in amending the relinking function as well.

Thanks for any input.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.