Changing ACCDE how can relink to the ACCDB file

We split our database into an ACCDE - code and forms and ACCDB - data files.

After making changes to the original db how do I relink the updated ACCDE file to the ACCDB.  The production ACCDB is not available to the development machine.

mlmcc
LVL 101
mlmccAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
You can incorporate the code below into your ACCDE - this is the de-facto standard:

http://access.mvps.org/access/tables/tbl0009.htm

And note the reference to the GetOpenFileName function ... to popup the Windows Standard File Browse dialog.

mx
0
 
mlmccAuthor Commented:
I'll give it a try.

Thanks

mlmcc
0
 
conagramanCommented:
mlmcc

here is the code i use:
' if the back end is password protected you can pass it by changing
' strConnect = ";DATABASE=" & dbpath
' to strConnect = ";DATABASE=" & dbpath & ";PWD=" & "your back end password" '& ;"



Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
Dim dbpath As String
Dim boolresult As String
Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "Back End|*.accdb"
objDialog.FilterIndex = 1

boolresult = objDialog.ShowOpen
Me.txtlocation = objDialog.FileName
dbpath = "c:/mydatabase.accdb"   ' ///////////////////////////////////////path to database here

strConnect = CurrentProject.Path
strConnect = ";DATABASE=" & dbpath


Set db = CurrentDb
For Each tdf In db.TableDefs

If tdf.Connect <> "" Then
tdf.Connect = strConnect
tdf.RefreshLink
End If
Next tdf

Set tdf = Nothing
Set dbs = Nothing
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
conagramanCommented:
the above code uses a text box i got rid of the bad line


Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
Dim dbpath As String
Dim boolresult As String
Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "Back End|*.accdb"
objDialog.FilterIndex = 1

boolresult = objDialog.ShowOpen
 
dbpath = objDialog.FileName   ' ///////////////////////////////////////path to database here

strConnect = CurrentProject.Path
strConnect = ";DATABASE=" & dbpath


Set db = CurrentDb
For Each tdf In db.TableDefs

If tdf.Connect <> "" Then
tdf.Connect = strConnect
tdf.RefreshLink
End If
Next tdf

Set tdf = Nothing
Set dbs = Nothing
0
 
mlmccAuthor Commented:
conagraman -  where do I put this code?
Do I add it to the ACCDE file and run it after installing on the client server?

The backend database will always be in the same folder with the ACCDE file.  Is there an easy way to tell it that?

mlmcc
0
 
mlmccAuthor Commented:
I haven't had a chance to try these since there have been no changes to the application.

The comments did remind of how to change the links manually and since they can all be done at one time I will probably do that with th enext changes.

Thanks

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.