Jumat, 16 Maret 2018

RE: [MS_AccessPros] Checking link tables

 

Looks like Art unsubscribed for some reason, but I'll post the code I use to relink tables anyway in case it helps others.

 

I use a local table with the version number of the back end plus a linked table with the same info. If they don't match I call the routine. Note this is done whenever the main form (usually my switchboard) is the active form. The strFileName is the path to the back end.

 

Public Function AttachTables(strFileName As String) As Boolean

'Purpose  : Relink tables to Front End.

'DateTime : 8/16/2004 10:19

'Author   : Bill Mosca

    Dim db As DAO.Database

    Dim tdf As DAO.TableDef

    Dim x As Variant

    Dim i As Integer

    Dim RetVal As Integer

    Dim wks As DAO.Workspace

   

    On Error GoTo err_AttachTables

 

    DoCmd.Hourglass True

   

    RetVal = True

    'Use an member of the Admins group.

    Set wks = DBEngine.CreateWorkspace("", "Admin", "")

    Set db = wks.OpenDatabase(CurrentDb.Name)

    x = SysCmd(acSysCmdInitMeter, "Attaching Tables: ", db.TableDefs.Count - 1)

   

    For i = 0 To db.TableDefs.Count - 1

        Set tdf = db.TableDefs(i)

        If Len(tdf.Connect & vbNullString) <> 0 And Left(tdf.Connect, 10) = ";DATABASE=" Then

            tdf.Connect = ";DATABASE=" & strFileName

            On Error Resume Next

            tdf.RefreshLink

           

            If Err <> 0 Then

              MsgBox "The selected file does not contain the required table(s):" _

                  & vbCrLf & tdf.SourceTableName, 16, "Incorrect Database"

              RetVal = False

            End If

           

            If Not RetVal = True Then

              Exit For

            End If

        End If

        x = SysCmd(acSysCmdUpdateMeter, i + 1)

    Next i

   

    x = SysCmd(acSysCmdRemoveMeter)

   AttachTables = RetVal

 

   

End Function

 

 

Regards,

Bill Mosca

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Friday, March 16, 2018 6:37 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Checking link tables

 

 

Does anyone have a way of checking linked tables. I have a Splash screen called frmSplash and this is the first form that is opened when the database starts. I have 50000 set on the timer event and in that time I would like to check and see if the backend needs to be relinked.

 

Can some one point me in the right the direction?

 

Thank you,

 

Art Lorenzini

Sioux Falls, sd

 

 

__._,_.___

Posted by: "Bill Mosca" <wrmosca@comcast.net>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar