Advertisement

08.07.2008 at 07:05AM PDT, ID: 23629325
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Relinking tables programmatically from password-protected database

Asked by AME123 in Access Coding/Macros, Microsoft Access Database, Access Architecture/Design

Tags: , , ,

I am looking for a way to pass a password ("XXX") programmatically from a password-protected back-end database (ClientData.mdb) to the front-end database (FrontEnd.mde) when linking tables programmatically.   Here is the situation.  

1.  I have a back-end database called ClientData.mdb; the database password is XXX.  The client does not know this password.
2.  I have a front-end database called FrontEnd.mde.
3.  When the client opens the front end they are prompted to relink the tables; clicking the button runs the code shown below, which relinks all the back-end tables into the front-end database.

The code below works perfectly (I have been using it for years) so long as the back end database is not password protected.  However, as soon as I password-protect the back end, the subroutine gets only as far as   tdf.RefreshLink  before it jumps to the "Err_b_ReattachTables_Click" part of the code.

According to the Microsoft Help page on the Connect property, I ought to be able to include a password as one of the paramaters in the Connect property - so I tried this by amending the line from
    tdf.Connect = ";DATABASE=" & Trim(strPrgFileFolder) & strPrgFileName
to
    tdf.Connect = ";DATABASE=" & Trim(strPrgFileFolder) & strPrgFileName & "PWD=XXX;"

However, the code still skips to the tdf.RefreshLink line, and then jumps to error code.

Note that if I did not put the "PWD=XXX;" in quotes the code turned red and kept giving me debug errors.

What am I doing wrong?  Is it just a problem of the syntax in the tdf.Connect line, or something else?

Please note that I am not a programmer by profession, so the answer needs to be specified in clear and simple terms!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
Private Sub b_ReattachTables_Click()
On Error GoTo Err_b_ReattachTables_Click
 
Dim strPrgFilePath As String
Dim strPrgFileName As String
Dim strPrgFileFolder As String
Dim strPrgFileName As String
Dim tdf As DAO.TableDef
 
strPrgFilePath = Application.CurrentDb.Name
strPrgFileName = Dir(strPrgFilePath)
strPrgFileFolder = Left(strPrgFilePath, Len(strPrgFilePath) - Len(strPrgFileName))
strPrgFileName  = "ClientData.mdb"
 
For Each tdf In DBEngine(0)(0).TableDefs
If ((tdf.Attributes And dbSystemObject) = 0) And (tdf.Connect <> vbNullString) And Not (tdf.Name Like "~*") Then
    tdf.Connect = ";DATABASE=" & Trim(strPrgFileFolder) & strPrgFileName 
    tdf.RefreshLink
    Me!lblMsg.Caption = "Linking..." & tdf.Name
    DoEvents
End If
Next
 
Me!lblMsg.Caption = ""
MsgBox "Linked tables have been re-attached", 64, "Attach Tables"
 
Exit_b_ReattachTables_Click:
    
    Exit Sub
 
Err_b_ReattachTables_Click:
 
    MsgBox "Please add back-end files to the current directory!", vbCritical, "Error Message No 1."
    Resume Exit_b_ReattachTables_Click
    
End Sub
 
Loading Advertisement...
 
[+][-]08.07.2008 at 04:05PM PDT, ID: 22186296

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Microsoft Access Database, Access Architecture/Design
Tags: Microsoft, Access, 2003, VBA
Sign Up Now!
Solution Provided By: LSMConsulting
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.07.2008 at 04:16PM PDT, ID: 22186343

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628