Relinking tables

J

John

I develop in 1 frontend which is linked to backend 1 (all users have their
own frontend). Another department uses the exact same application but with
their own backend, backend 2. Whenever the frontend is updated I would like
to run a routine that relinks a copy of the frontend to backend 2. I'd like
the code to run without prompting. I tried (modifying) this code
http://www.mvps.org/access/tables/tbl0009.htm but it's over my head. I can't
get it to work. I don't really get what all the code does. Is there some
more simple code or other ideas to make this routine?
Thank you.
John
 
J

John

I just found other code that looks even easier to implement. Or does this
code miss crucial parts?
John

'RelinkTables...Just as the name suggests pass a path to a database to this
sub
'eg RelinkTables("c:\windows\test.mdb")
'and it will go through all the tables in your
'database and link them to the new location
'Written by John Hawkins 20/9/99 www.fabalou.com
Public Sub RelinkTables(NewPathname As String)
Dim Dbs As Database
Dim Tdf As TableDef
Dim Tdfs As TableDefs
Set Dbs = CurrentDb
Set Tdfs = Dbs.TableDefs
'Loop through the tables collection
For Each Tdf In Tdfs
If Tdf.SourceTableName <> "" Then 'If the table source is other than
a base table
Tdf.Connect = ";DATABASE=" & NewPathname 'Set the new source
Tdf.RefreshLink 'Refresh the link
End If
Next 'Goto next table
End Sub
 
P

Peter Hibbs

John,

I haven't tried that routine but I guess it does the job. I don't
think it omits anything crucial, the main difference from my code is
that you have to supply the pathname for the back-end file in code
whereas my code assumes that the developer would not necessarily know
where the back-end file was saved on the user's system, so it allows
the user to specify the pathname on the first use and then saves that
pathname in the .ini file for all subsequent use.

Also, if you have several users on a network, the pathname to the
back-end server *could* be different (although it generally isn't)
which allows each user to store their own back-end pathname, if
required. With this code I think you would have to make sure that your
developer version and all the users on the network had exactly the
same pathname from front-end to back-end.

If it works for you then it should be fine.

Useful Web site, by the way, haven't seen that one before.

HTH

Peter Hibbs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top