Relink To Backend DB that Protected

G

Guest

Hallo

I would like to relink my Front end DB with a Backend DB that password
protected

This is the code i am using at the moment but its missing the part for the
password.

On Error GoTo Startup_Err
Dim tdf As DAO.TableDef
Dim strD As String
Dim strC As String
Dim strMM As String
Dim strFilename As String
Dim strIMEX As String
Dim db As DAO.Database
Set db = CurrentDb

strD = "\\cmms acr log\tables\"


DoCmd.OpenForm "frmLinkingTables"


For Each tdf In CurrentDb.TableDefs
If Len(Nz(tdf.Connect, "")) > 0 Then ' non-local
If Right(tdf.Connect, 3) = "dat" Then
If InStr(tdf.Connect, strD) = 0 Then ' need to
reconnect
Forms!frmLinkingTables!lblTable.Caption = tdf.Name
strIMEX = Left(tdf.Connect, InStr(tdf.Connect,
"Database=") + 8)
strC = strIMEX & strD & "tables.dat"
tdf.Connect = strC
tdf.RefreshLink
DoEvents
End If
Else
strFilename = getfile(Mid(tdf.Connect, 11))
If InStr(tdf.Connect, strD) = 0 Then ' need to
reconnect
Forms!frmLinkingTables!lblTable.Caption = tdf.Name
tdf.Connect = (";DATABASE=" & strD & strFilename)
tdf.RefreshLink
End If
End If
End If
Next
DoCmd.Close acForm, "frmLinkingTables"

Startup_Exit:
Exit Sub

Startup_Err:
If Err.Number = 2450 Then 'form is missing
MsgBox "Cancelling Linking"
Resume Startup_Exit
Else
MsgBox Err.Description
Resume Startup_Exit
End If
End Sub
 
G

Guest

You can include the password in the Connect property. I don't remember the
syntax, exactly, but here is how you can figure it out.

Use the Linked Table Manager to link to one of the tables in the protected
database. When you try to establish the link, it will ask you for the
password. Once the link is successful, this will return the connect string
with the password syntax in it that you can use to modify your code:

?CurrentDb.TableDefs("TheTableName").Connect
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top