setting backend path from code

J

Jesper F

The person I'm developing a split database for places the
backend database in F:\database\BE\ (won't change).
I'd like to set this path before I email him the db so
that it works without him having to relink the tables. I'm
trying to use the following to relink them, but it doesn't
work since there's no F-drive on my own computer and I'm
getting the network error.

Dim db As Database, tdf As TableDef
Set db = CurrentDb
For Each tdf In db.TableDefs
tdf.Connect = ";DATABASE=F:\database\BE\dbname"
'tdf.RefreshLink
Next

This fails to relink them, but if I uncomment
the .refreshlink line I get the network error since
there's no F-drive.
Can I set a path that I know will work on the customers
computer even though the path doesn't exist on my own
computer?
Ps. I'd prefer to not let the user browse the open-file
dialog to look for the backend - therefore this approach.
 
G

Guest

You can check to see if a path is valid and then act accordingly:
If Len(Dir("F:\database\BE\dbname")) > 0 then
'path is valid
Else
'path is not valid
End If

TomU
 
J

Jesper F

You can check to see if a path is valid and then act
accordingly

Yes, but I'm not sure that'll help me. I just want to set
all the linked tables' connect properties
to ";DATABASE=F:\database\be" even though that path
doesn't exist on my computer. I seem to only be able link
to paths that exist on my computer.
 
G

Guest

You can optionally perform the refreshlink or not based on the results of the
Dir test.
 
J

Jesper F

You can optionally perform the refreshlink or not based
on the results of the Dir test.

All right, so it's not possible to set a path that doesn't
exist on my computer and then email the db. I have to
write the code snippet, so that it's run on db startup. I
was just trying to see I could skip this since I know the
customers backend path.
Thanks anyway.
 

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