Dear Gents,
I have a software i already separated the backend to be more reliable for our work.
I added a password for it to be more secure .
I found that code on internet that check if the tables are linked or not and if not , it ask for new location by opening wizard to select the new location .. But it's not working with password .. Can vba experts edit that code to be working on encrypted backend.
Here's the code.
Code:
On Error Resume Next
Dim fDialog As Office.FileDialog
Dim td As TableDef
Dim db As DAO.Database
Dim strOld As String
Dim strNew As String
Set db = CurrentDb
strOld = Mid(db.TableDefs("TableName").Connect, 11)
If Dir(strOld) = "" Then
MsgBox "Can't Find Database source , Please select another Database", vbInformation
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "Please choose Database location"
.InitialFileName = "C:\" 'use appropriate drive letter
.Filters.Clear
.Filters.Add "Access file", "*.accdb"
If .Show = True Then
strNew = .SelectedItems(1)
For Each td In db.TableDefs
If InStr(td.Connect, strOld) > 0 Then
Debug.Print td.Name
Debug.Print "Old Link: " & td.Connect
td.Connect = Replace(td.Connect, strOld, strNew)
td.RefreshLink
End If
Next td
Else
MsgBox "Canceled", vbInformation
End If
End With
End If