I have an access 2007 database that has a password protected back end. I distribute the application using the MS Package Solution. I have a clean version of the back end that the application links to at first run, and I use an identical version of the back end for development, so the front end is not linked to the user's back end prior to install.
The problem I have is that on first run the application prompts the user for the back end password, despite having the following function in place that runs first in autoexec to relink all pertinent tables and supply the password. This function works perfectly to relink the tables, yet the user is still asked for the password.
How can I get past the initial password prompt without linking to the clean back end prior to install?
- Is it necessary to also place the password in the .connect?
- Is specifying the current database prior to relinking the tables prompting the password request?
- tblBEPathName is the only table that is referenced prior to supplying the password and linking the back end tables, and it resides in the front end. Does referencing a table that is not a linked table still produce the password prompt?
Public Function UpdateReLink()
Dim dbs As Database
Dim dbsLink As DAO.Database
Dim tdf As TableDef
Dim strPathName As String
Dim strFilename As String
If DCount("[txtPath]", "tblBEPathName", "[Active]=Yes") = 0 Then Exit Function
If CurrentProject.AllForms("DetectIdleTime").IsLoaded = True Then DoCmd.Close acForm, "DetectIdleTime", acSaveNo
strPathName = DLookup("[txtPath]", "tblBEPathName", "[Active]=Yes")
strFilename = DLookup("[txtFileName]", "tblBEPathName", "[Active]=Yes")
If StrComp(Right(strPathName, 1), "\", vbTextCompare) <> 0 Then strPathName = strPathName & "\"
Set dbs = CurrentDb()
Set dbsLink = DAO.DBEngine(0).OpenDatabase(strPathName & strFilename, False, False, ";pwd=12345")
On Error GoTo UpdateRelink_Error
Err = 0
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 0 Then
SysCmd SYSCMD_SETSTATUS, "Linking " & tdf.Name
tdf.Connect = ";DATABASE=" & strPathName & strFilename
DoCmd.RunMacro "Terminal ID: Get Current"
DoCmd.OpenForm "DetectIdleTime", acNormal, , , , acHidden