Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Table Connections Error
Kim Nielsen 
      
3 years ago
Hopefully someone can help me out here. DBase 1 has linked tables to DBase 2. There was a crash on DBase1. Now when it checks for the correct tables in DBase 2 it is now looking for ~TMPCLP348951. How do i get the DBases to not look for these? I use the code created here to check to ensure we are connected to DBase 2. Using a Global Module it was working fine until this happened now i can not get out of this?

This is link table code.


Code
Public Function TableIsLinked(TableName As String)

    Dim rs As Recordset
    
    On Error GoTo TableErr
    Set rs = CurrentDb.OpenRecordset(TableName)
    rs.Close
    Set rs = Nothing
    TableIsLinked = True
    Exit Function
      
TableErr:
    TableIsLinked = False
    
End Function
Public Function GetLinkFilename(TableName As String) As String

    Dim FN As String, curfolder As String
    
        If MsgBox("Please select the correct Data Storage FD Air Fill BE, containing the necessary tables:" & TableName, _
        vbOKCancel + vbCritical, "Tables Not Found") = vbCancel Then
            Quit
    End If
    
    
    curfolder = CurrentProject.Path & "\*.ACCDB"
    FN = PickFile(curfolder)
    If FN = "" Then Quit
    
    GetLinkFilename = FN

End Function
Public Function LinkTable(td As TableDef, FN As String)

    On Error GoTo LinkFail
    Echo True, "Relinking " & td.Name
    td.Connect = ";DATABASE=" & FN
    td.RefreshLink
    LinkTable = True
    Exit Function
        
    
LinkFail:
        LinkTable = False

End Function


Public Sub CheckForDataFile()

    Dim td As TableDef, FN As String
    
    FN = ""
        
    For Each td In CurrentDb.TableDefs
        If (td.Attributes And dbAttachedTable) Then
            If Not TableIsLinked(td.Name) Then                      'This relates to Public Function Tablename
                If FN = "" Then FN = GetLinkFilename(td.Name)       'This relates to public function GetLinkFilename
                While Not LinkTable(td, FN)                         'This relates to public function LinkTable
                    FN = GetLinkFilename(td.Name)
                Wend
            End If
        End If
    Next

End Sub

    

Public Function PickFile(Optional InitialFolder As String = "") As String

On Error Resume Next
Dim FO As Object
Set FO = Application.FileDialog(3)
If InitialFolder <> "" Then FO.InitialFilename = InitialFolder
FO.Show
PickFile = FO.SelectedItems(1)

End Function

Kevin Robertson  @Reply  
          
3 years ago
Add a check in your For...Each loop.
If Not (td.Name Like "MSys*" Or td.Name Like "~*") Then
Scott Axton  @Reply  
        
3 years ago
It might be that what ever crashed your db caused some corruption.
If you haven't already I would try and determine, if it isn't to late, what the cause of the crash was.

If you aren't doing so already Back up your whole db.  Front and back end as well as DB2.
Then open each individually and do a Compact and Repair.  It might be you have lingering effects from the crash.
Kim Nielsen OP  @Reply  
      
3 years ago
I completed this, not sure what the cause of the crash was. Still trying to figure it out. I do this copy of DB's and completed a compact and repair. The problem still came back. But the redo of the original DB was successful. Thank you

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 4:25:36 AM. PLT: 1s