Code to find backend table.

  • Thread starter Thread starter Lee Taylor-Vaughan
  • Start date Start date
L

Lee Taylor-Vaughan

Hello

I have a problem when a database loads and the back end (data tables) cannot
be found. the problem is that the database continues to load and does not
launch the "table Manager", or ask the user to locate the back end/data
tables.

Is this a part of access to automatically ask the user where the back end
is, or is this something that has to manually be coded upon loading the
Database.... if so, can some please point me in the right direction of how
to code for this...

Thanks

Lee
 
You have to code it.

One way: In the OnCurrent event of your main menu form, do a Dlookup on one
of your linked tables. If the link is no good, an error will be generated.
Trap for that error and open a Data Link form with appropriate field to enter
the correct path and database file name (or use the FileDialog Object to
browse for the database).

Once the field is filled in with the database path and name, you can use
this code in the click event of a command button to relink:
'reattach tables
Set dbCurrent = CurrentDb
dbname = CStr(ctltxtPath) 'Field with the path and db name.
For I = 0 To dbCurrent.TableDefs.Count - 1
Set tmptable = dbCurrent.TableDefs(I)
If tmptable.Connect <> "" Then
tmptable.Connect = ";Database=" & dbname
tmptable.RefreshLink
End If
Next I
 
Back
Top