Solved

Access 2007 Split DB - Linked Table Manager

Posted on 2013-11-21
30
399 Views
Last Modified: 2013-11-22
I have an Access 2007 Split DB (front & backend). I am distributing the front end to different users in different sites. The issue is re-linking the tables. How do I program when the front end is opened by the user that it checks and re-links their backend tables for them?
0
Comment
Question by:CMILLER
  • 16
  • 9
  • 5
30 Comments
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
There are plenty of free utilities available to do this.  Check out the downloads for Relinker samples here:
http://www.jstreettech.com/downloads.aspx
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<I am distributing the front end to different users in different sites.>

is the BE the same for all your users?
0
 

Author Comment

by:CMILLER
Comment Utility
mbizup: I cant install software.



capricorn1: Yes, BE will be the same.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
This blog post explains how to relink at startup... similar code to what you'll find in those samples:
http://blogs.office.com/b/microsoft-access/archive/2012/08/03/how-to-automatically-relink-microsoft-access-tables-.aspx
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
place this code in a regular module

Sub RelinkTables()
On Error GoTo Relink_Error
Dim dbs As DAO.Database, strBEPath As String
Dim tdf As DAO.TableDef
Set dbs = CurrentDb()
strBEPath = "<complete path to your backend>"
Dim dbData  As DAO.Database
Set dbData = DBEngine.OpenDatabase(strBEPath)
     For Each tdf In dbs.TableDefs
          If tdf.Connect <> "" Then
               tdf.Connect = ";DATABASE=" & strBEPath
               tdf.RefreshLink
          End If
     Next
dbData.Close
Set dbData = Nothing

Relink_Error:
     If Err.Number = 3024 Then
          MsgBox "Unable to connect to data tables!" & vbCrLf & "Closing Application", vbQuestion, "DATA TABLES MISSING!"
          Err.Clear
           Application.Quit
     End If
End Sub


you can call the sub in the open or load event of your startup form.



.
0
 

Author Comment

by:CMILLER
Comment Utility
"you can call the sub in the open or load event of your startup form."

How do I do that?
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
place this codes in the open event of your startup form

private sub Form_Open(cancel as integer)

RelinkTables

end Sub
0
 

Author Comment

by:CMILLER
Comment Utility
I am getting an error here

Private Sub Form_Open(Cancel As Integer)
code-error.JPG
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
what is the error?
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Did you read/follow the detailed instructions at the link I posted in my last comment? (The code that cap1 posted is very similar).
0
 

Author Comment

by:CMILLER
Comment Utility
I attached the error
0
 

Author Comment

by:CMILLER
Comment Utility
mbizup: I just looked at the link you posted. The issue is that I will have the backend in a network folder and the front end will be on several users desktops.

one of the requirements for your code is that both files have to be in the same folder.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<I attached the error >

that does not tell us anything.. is there any error message? post them here
0
 

Author Comment

by:CMILLER
Comment Utility
no error message, but it seemed to work after I had both files in the same network folder but thats not how I will them.

The backend will be on a network share and the front end will be on users desktops.
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
The idea there is to relink a single copy of the front end before distributing it to the users, rather than relinking separate copies on the users individual computers.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
With that approach, you relink *once* and then distribute a properly linked FE to your users.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
<no error message, but it seemed to work after I had both files in the same network folder but thats not how I will them.>

it will work where ever you place the FE. as long as you specify in the code the path to the BE


strBEPath = "<complete path to your backend>"


can  you post what did you place as the path to the BE
0
 

Author Comment

by:CMILLER
Comment Utility
strBEPath = "\\Server-name\Files\#DATABASES\DB-REMOTE\TEST1\REMOTE_be.accdb"
0
 

Author Comment

by:CMILLER
Comment Utility
I added the action in my autoexec macro.

RunCode - RelinkTables()
OpenForm - Main-Menu,form,,,,Normal
0
 

Author Comment

by:CMILLER
Comment Utility
The issue is that I am distributing the FE to users on different networks, while maintaining the master FE for updates.
0
 

Author Comment

by:CMILLER
Comment Utility
Do I need a buttons on my main menu for the different users network, so they run the script for there network.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
so you are calling the codes from a macro, then you need to change the "SUB" to "FUNCTION"


change this

Sub RelinkTables()

with

Function RelinkTables()
0
 

Author Comment

by:CMILLER
Comment Utility
Changed to Function but still didnt work.
0
 

Author Comment

by:CMILLER
Comment Utility
Ok, I got it working. There was an issue with module names and what I had in the autoexec.

When I open the FE from my desktop it connects to the path in the RelinkTables.

I think I will change it to buttons on the main screen for the different users. I will create seperate relinktables and buttons.

Thanks, for the help!
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
where did you place the "RelinkTables" codes  ?
0
 

Author Comment

by:CMILLER
Comment Utility
I created the module "Function Name RelinkTables()"

With the code that you first gave me.

Then added the first line action "RunCode" with "RelinkTables()" for the arguments.
0
 

Author Comment

by:CMILLER
Comment Utility
Then added the first line action "RunCode" with "RelinkTables()" for the arguments in the autoexec macro.
0
 

Author Comment

by:CMILLER
Comment Utility
Sorry, something I just realized is that when it wasnt working I wasnt getting the Relink_Error msgbox.
0
 

Author Comment

by:CMILLER
Comment Utility
I need to add a msg after a successful relink
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
Sub RelinkTables()
On Error GoTo Relink_Error
Dim dbs As DAO.Database, strBEPath As String
Dim tdf As DAO.TableDef
Set dbs = CurrentDb()
strBEPath = "<complete path to your backend>"
Dim dbData  As DAO.Database
Set dbData = DBEngine.OpenDatabase(strBEPath)
     For Each tdf In dbs.TableDefs
          If tdf.Connect <> "" Then
               tdf.Connect = ";DATABASE=" & strBEPath
               tdf.RefreshLink
          End If
     Next
dbData.Close
Set dbData = Nothing

'add this line
if err=0 then
msgbox "Linking process successful"
end if


Relink_Error:
     If Err.Number = 3024 Then
          MsgBox "Unable to connect to data tables!" & vbCrLf & "Closing Application", vbQuestion, "DATA TABLES MISSING!"
          Err.Clear
           Application.Quit
     End If
End Sub
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now