P
polparrot via AccessMonster.com
I have a database with 4 tables. 2 are from an external database called
controllers.mdb
This database is run in 2 places. The primary location is on a server and
all computers on the server point to "r:\r&m\site_info_sheets\maindatabase.
mdb". The secondary location is a laptop that goes with a tech in the field
so it is no longer connected to the server. The databse then resides on the
laptops c: drive with the same path. I am trying to set the code such that
the access database can be copied from the server to the laptop and when the
master form is loaded or opened then the tables will be relinked to the
controller.mdb on the c: drive as opposed to the r: drive.
I have placed the following code in my Open event of my master form:
Private Sub Form_Open(Cancel As Integer)
Dim db As dao.Database
Dim tdf As dao.TableDef
Dim strConnect As String
Dim strdir As String
strdir = CurrentProject.Path
strConnect = ";DATABASE=" & strdir & "\controllers.mdb"
Set db = CurrentDb
For Each tdf In db.tabledefs
tdf.connect = strConnect
tdf.refreshlink
Next tdf
Set tdf = Nothing
Set dbs = Nothing
End Sub
This code I got from another thread.
Any help on why this is not working would be greatly appreciated.
Polly
controllers.mdb
This database is run in 2 places. The primary location is on a server and
all computers on the server point to "r:\r&m\site_info_sheets\maindatabase.
mdb". The secondary location is a laptop that goes with a tech in the field
so it is no longer connected to the server. The databse then resides on the
laptops c: drive with the same path. I am trying to set the code such that
the access database can be copied from the server to the laptop and when the
master form is loaded or opened then the tables will be relinked to the
controller.mdb on the c: drive as opposed to the r: drive.
I have placed the following code in my Open event of my master form:
Private Sub Form_Open(Cancel As Integer)
Dim db As dao.Database
Dim tdf As dao.TableDef
Dim strConnect As String
Dim strdir As String
strdir = CurrentProject.Path
strConnect = ";DATABASE=" & strdir & "\controllers.mdb"
Set db = CurrentDb
For Each tdf In db.tabledefs
tdf.connect = strConnect
tdf.refreshlink
Next tdf
Set tdf = Nothing
Set dbs = Nothing
End Sub
This code I got from another thread.
Any help on why this is not working would be greatly appreciated.
Polly