Hard code link to back-end

H

Harmannus

Hallo,

Below is a link to set the path to a back-end. I want to hard-code the path
to the back-end (as i do editing on a other PC and i do not have access to
the server back-end).

http://www.mvps.org/access/tables/tbl0009.htm

My VBA knowledge is not that good and i do not understand everthing that is
done in the code. I tried to comment out some parts but can't get it right.

Who can give my pointers as to what parts of the code i must use/change so
that i can hard code the path myself.

Thanx for any help.

Regards,
Harmannus
 
R

Roger Carlson

You don't need all that if you just want to hard-code a path. You can do
something as simple as this:

Dim Directory As String
Dim FileName As String
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Set db = CurrentDb

'create string for drive where program exists
Directory = "C:\the\path\to\thefile\"
FileName = "MyBackend.mdb"
'delete the linked table
db.TableDefs.Delete "MyTable"

'reattach table from new database
Set tbl = db.CreateTableDef("MyTable")
tbl.Connect = (";DATABASE=" & Directory & Filename)
tbl.SourceTableName = "MyTable"
db.TableDefs.Append tbl
db.Close

On my website (see sig below) is a small sample database called
"LinkTables.mdb" which illustrates how to choose which database you want to
connect to using code similar to that above.
 

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