[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Re-Link data question

Posted on 2015-01-29
10
Medium Priority
?
159 Views
Last Modified: 2015-01-29
Hi EE

I have the following code to re-link my data
Dim path
path = "C:\PPTdata"
DBFile = CurrentProject.path & "\PPTdata.mdb"
strFile = Dir(DBFile)
If strFile <> "" Then
    With CurrentDb
        For Each tdf In .TableDefs
            If tdf.Connect Like "*PPTdata.mdb*" Then
                tdf.Connect = ";DATABASE=" & DBFile
                tdf.RefreshLink
            End If
        Next
    End With
    MsgBox "Link PPTdata.mdb"
Else
    MsgBox "Problem"
End If

The data is password protected how would I modify the code to include password

chestera
0
Comment
Question by:chestera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 1000 total points
ID: 40578716
Something close to this ...

tdf.Connect = ";DATABASE=" & DBFile & ";PWD=" & "YourPassword" & ";"
0
 

Author Comment

by:chestera
ID: 40578726
DatabaseMX

Yep I tried  password=pwd  after the DBfile couldn't get the correct syntax. I will try now
Thank you

Alan
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 40578734
try

dim strPassword as string

strPassword="yourPassword

change this

 tdf.Connect = ";DATABASE=" & DBFile

with

 tdf.Connect = ";DATABASE=" & DBFile& ";PWD=" & strPassword
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:chestera
ID: 40578764
Rey Obero

Tried Max code and it worked. Thank you

Alan
0
 

Author Comment

by:chestera
ID: 40578778
DatabaseMX

Your line of code Worked fine.

 I know this is not part of the question but I am running the program from a development folder which also contains the data.
DBfile = currentProjectpath.Path picks up the Development folder and links to the data.mdb
The data is going to reside on a server so would like to re-link to the server. Do I   need different code to achieve this or can it be modified.

Alan
0
 
LVL 75
ID: 40578808
Anytime you relink .. the Password with need to be part of the Connect (aka Connection) string ... one way or another.

mx
0
 

Author Comment

by:chestera
ID: 40578809
DataBaseMX

Sorry Max forget last responce from me
I just change the DBfile = ServeData

Alan
0
 
LVL 75
ID: 40578813
Max ?
0
 

Author Closing Comment

by:chestera
ID: 40578832
Many thanks for your help
0
 

Author Comment

by:chestera
ID: 40578840
DatabaseMX
Sorry for the confusion MX I asked another  question see below
 I know this is not part of the question but I am running the program from a development folder which also contains the data.
DBfile = currentProjectpath.Path picks up the Development folder and links to the data.mdb
The data is going to reside on a server so would like to re-link to the server. Do I   need different code to achieve this or can it be modified.

I worked it out
Instead of DBfile = currentProject.Path
I used
DBfile = ServicePath\Data.mdb
All works fine

Alan
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question