Refreshing links to data mdbs of unknown location 95 
Author Message
 Refreshing links to data mdbs of unknown location 95

Try this code. I wrote this for an app that I knew would have the same
problem you're experiencing.

It consists of two functions, one to check if the tables are attached, the
second to reattach them. I only use one table, "MyTable" as an example for
reattaching the table, just repeat the code for all the tables you need to

The CheckAttachedTable function fires on the OnLoad of the Switchboard. You
have to include the comdlg32.ocx as a control on the Switchboard so your
users can find the mdb file they need. Because you are distributing an ocx,
you must include mfc40.dll, msvcrt40.dll, olepro32.dll and comdlg32.ocx
itself in the setup you create for your app. Read the knowledge base on
distributing ocx's for detailed information, it is tricky.

Good luck....

Option Compare Database
Option Explicit

Public Function CheckAttachedTable()
    Dim db As DATABASE, strName As String, sTableName As String
    On Error Resume Next
    sTableName = "MyTable"
    Set db = CurrentDb()
    strName = db.TableDefs(sTableName).Fields(0).Name
    If Err.Number <> 0 Then
        Call ReattachTable
    End If
    On Error GoTo 0
End Function

Public Function ReattachTable()
    Dim db As DATABASE, tdf As TableDef, sFilePath As String, sMsg As
String, iResponse As Integer
    On Error Resume Next
        If Err.Number = 32755 Then      ' Cancel Error from Common Dialog
            sMsg = "Tables must be reattached to run application." & vbCrLf
& "Click OK to quit application"
            iResponse = MsgBox(sMsg, vbOKOnly, "My Sample Database")
            Exit Function
        End If
    sFilePath = Forms!Switchboard!ComDlg.FileName

        Set db = CurrentDb()
        Set tdf = db.TableDefs("MyTable")
            tdf.Connect = ";DATABASE=" & sFilePath
End Function

Mark J. Brown

QuickStart Technologies, Inc.
1500 Quail Street 6th Floor
Newport Beach, CA 92660

> I am trying to create an application in two pieces (data.mdb and
> program.mdb).  I want to store the data on the network and the program on
> the local drive (speed etc.).  I have found suggestions from the newgroup
> on how to refresh the links to attached tables when the data and program
> are in the same directory.  I have also found suggestions for when they
> aren't in the same directory but you (programmer) know where the data
> be.  Unfortunately, this file will likely get moved several times and the
> drive pathing varies by computer within the network (f: on one computer
> g: on another).  

> In access 2.0 I had a routine someone wrote that could determine whether
> the data was in the expected location, and if not it used the msau200.dll
> to let the user find the file (similar to the open file dialog).  It then
> used a couple of wrapper functions to parse out the path and file
> information and work it's magic to reconnect the tables.  

> I have figured out that msau200.dll has been replace by msau7032.dll.
> wrapper functions however completely elude me.  If you have a solution or
> would be willing to view/review old code to help me find a solution, I
> would greatly appreciate it.

> --

> Potomac Consulting Group
> Arlington, VA

Tue, 02 Nov 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Extracting data from unknown locations in unique files of unknown size

2. Access 95 Procedure to link application to multiple data mdb files in same directory

3. Change Access database Location but data not refresh !!!

4. Refreshing and Data Locations

5. Unknown Error while installing Mdac_typ 2.5 on Windows 95

6. Refreshing Data on a linked table...

7. Refreshing Data on a linked table...

8. Location of Windows 95 API Helpfile

9. Data Control with v2.0 .MDBs

10. Windows 95 Start Menu Refresh

11. Refresh the Win 95 desktop

12. Establishing DDE links with unknown fields at run time


Powered by phpBB® Forum Software