Results 1 to 6 of 6
  1. #1
    Lowell is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Location
    Manitoba, Canada
    Posts
    54

    Refresh Table Links Code

    I am trying to make a deployment package. Of course I have a split database and I want to have my tables automatically linked when it gets to the customers computer and is installed.

    I have tried copying and pasting the code from here:



    http://blogs.office.com/b/microsoft-...s-tables-.aspx

    But it tells me that it doesn't work. And it doesn't!! When I test it on a computer without Access I get two messages: This file is a read only file, save this database to make design changes; and when I try to edit data: The file path: C:\%username&\Programs(x86)\recordkeeping_be.accdb is invalid. Make sure linked tables are on the same computer in the right folder.

    This is the start of it:

    Option Compare Database
    Private Sub Form_Open(Cancel As Integer)
    '----------------------------------------------------------------------------
    ' Procedure: RefreshTableLinks
    ' Purpose: Refresh table links to back-ends in the same folder as front end.
    ' Note: Linked Tables can be in more than one back-end.
    ' Return: Returns a zero-length string if all tables are relinked.
    ' Return: Or returns a string listing tables not relinked and errors.
    '----------------------------------------------------------------------------

    (MY WORDS HERE: a cursor comes here and a message box pops up that says Compile Error: Expected End Sub?????????????)

    Public Function RefreshTableLinks() As String
    On Error GoTo ErrHandle

    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim strCon As String
    Dim strBackEnd As String
    Dim strMsg As String
    Dim intErrorCount As Integer

    Set db = CurrentDb

    'Loop through the TableDefs Collection.
    For Each tdf In db.TableDefs
    'Verify the table is a linked table.
    If Left$(tdf.Connect, 10) = ";DATABASE=" Then
    'Get the existing Connection String.
    strCon = Nz(tdf.Connect, "")


    I never have understood coding. My skull is too thick. Can you clearly explain what I need to do?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Take another look at the tutorial. You declare a Sub procedure then don't end it but go right into a Function declaration. Either delete the Function declaration and modify code to run directly in the Sub procedure or call the Function from the Sub:

    Code:
    Private Sub Form_Open(Cancel As Integer)
    Dim strMsg As String
    'Run the Procedure, getting any error messages.
    strMsg = RefreshTableLinks()
    'strMsg will be a zero-length string if there is no error message.
    If Len(strMsg & "") = 0 Then
       Debug.Print "All Tables were successfully relinked."
    Else
       'Notify the user of the errors.
       MsgBox strMsg, vbCritical
    End If
    End Sub
    
    Public Function RefreshTableLinks() As String
    ....
    End Function
    However, I question a split design that has frontend and backend in the same folder. If this is a multi-user db, the frontend should be copied to each user's workstation and the table links should use UNC pathing.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Lowell is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Location
    Manitoba, Canada
    Posts
    54
    The only reason for a split is for updates down the road sometime. I am certain that there will be need for that.

    It is only a single user program because there are a few organizations of a similar kind but that deal with different personal data because of different localities. The data is only for a the region in which the program user is using it.

    The code worked so far.

    Thanks a lot. I will now deploy and run another test on the testing computer. I will check back after that. I think there is another problem brewing but first we will deal with this.

    Thanks for now.

  4. #4
    Lowell is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Location
    Manitoba, Canada
    Posts
    54
    Well it worked on my developer computer but not after deployment. It has something to do with not being able to do design changes after making an install package with Access Runtime.

    I have attached some screen shots for your information. Maybe you can help me trouble shoot this??

    Click image for larger version. 

Name:	Screen1.jpg 
Views:	7 
Size:	53.0 KB 
ID:	11426Click image for larger version. 

Name:	Screen2.jpg 
Views:	6 
Size:	56.8 KB 
ID:	11428Click image for larger version. 

Name:	Screen3.jpg 
Views:	5 
Size:	66.2 KB 
ID:	11429Click image for larger version. 

Name:	Screen4.jpg 
Views:	6 
Size:	61.0 KB 
ID:	11430

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I have never deployed for runtime, never converted to an accde. If can't programmatically set links because it is a design modification, then I don't have solution. Try Google search.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Lowell is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Location
    Manitoba, Canada
    Posts
    54
    Well I've spent the last 3 hours on Google and I found what I needed, sort of. But of course, the best I've found out is to use my own head which seems to be one of the better solutions when all else runs out and everyone can't get it figured out. I got it all myself.

    All I did was tell the installer to put it in a different folder than I had been sending it to. I was sending it to Program Files (x86), but instead I sent it to My Documents folder and it works beauitully now. Thanks anyhow for trying. I will mark this as solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Issue with Table Links in MS Access 2010
    By sesling in forum Access
    Replies: 2
    Last Post: 12-24-2012, 08:14 AM
  2. Form Code refresh on open
    By mseeker22 in forum Forms
    Replies: 2
    Last Post: 07-08-2011, 12:35 AM
  3. Refresh links on start up
    By snoopy2003 in forum Database Design
    Replies: 3
    Last Post: 03-19-2011, 04:13 AM
  4. Replies: 3
    Last Post: 10-04-2010, 01:31 PM
  5. update imported table like a refresh
    By cmul in forum Access
    Replies: 1
    Last Post: 09-02-2010, 09:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums