table linking using VBA

  • Thread starter Chris Mortimore
  • Start date
C

Chris Mortimore

i am trying to write a procedure that will do the following...

1. Try to open the linked table called "Data" (ie, having a form with its
RecordSource set to "Data" and opening the form).
2. If opening "Data" fails, remove the link, ask the user to enter the path
of the database that holds "Data", make a new linked table and try step 1
again
3. When "Data" can be opened (ie, when the path is correct), save this link
in the mdb file so next time it'll try and open the same path (so if the
database gets moved to a different folder on the server, the new path only
needs to be entered once).

can somebody give me a hint on how to do this? i'm not too hot in the ways
of VBA.

thanks
 
S

SJ

you will need to write some code..

I suggest,

do a select from the table after an on error resume next (before opening
the form)
if err.number = 0 then the select was successful

if err <> 0 then an error occurred and you need to relink the table via
code.

You could pop up an openfile dialog box and let the user select the
database and then delete/relink the table...

have a look at the tabledef object in DAO... as I say, you will need to
write some code...
 

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