Any ideas how to do this using a combobox?
Assuming the back end is a native Access database file, the following is a stripped down version of some code from one of my own applications. Name your combo box cboBackEnd and set it up so that it lists the paths to the various back end files, or these could
be in a hidden bound first column with a plain English description of each in the second visible column. Paste the code into the combo box's AfterUpdate event procedure;
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim strMessage As String, strBackEnd As String
Set dbs = CurrentDb()
If IsNull(Me.cboBackEnd) Then
strMessage = "Path to source database must be " & _
"selected before updating links."
MsgBox strMessage, vbInformation, "Warning"
Exit Sub
Else
strBackEnd = Me.cboBackEnd
End If
strMessage = "Are you sure you wish to link to " & _
strBackEnd & " as the source database?"
If MsgBox(strMessage, vbOKCancel + vbQuestion, "Leave Planner") = vbCancel Then
Exit Sub
End If
If Dir(strBackEnd) = "" Then
strMessage = "The database you have specified as the " & _
"source was not found."
MsgBox strMessage , vbInformation, "Warning"
Exit Sub
End If
For Each tdf In dbs.TableDefs
If tdf.Connect <> "" Then
tdf.Connect = ";DATABASE=" & strBackEnd
tdf.RefreshLink
End If
Next tdf
strMessage = "Linking completed."
MsgBox strMessage, vbInformation, "Confirmation"