Progammatically link to backend dbs

J

J.J.

I earlier posted this question under general questions but soomeone gave a
blank answer so I thought this question might fit better with coders anyhow.
Existing threads I have scoured discussing linking to backends all have
unique issues that do not address my more basic issue. I have a couple of
users who are not computer skilled enough to use Link Manager so I would like
to programmatically link to the master backend when hooked to the server and
to the local replica backend when in the field with a laptop. I envision
something like:
If: hooked to server site Then: use server mdb as backend
else set dbs backend to predefined local replica. Conflicting info makes me
unsure or even if to use something like Set dbsCurrent = CurrentDb. If you
can point me to an example this would be much appreciated but I am sure there
is a much more elegant and simple way to do this. Thank you
 
D

Daniel Pineault

You can use the code found at

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

to relink your table automatically.

Then make a slight mod before setting the path to be use by first performing
a test to see if the path to the server exists or not. If it does use that
path, else use a path set for your laptop.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
D

dymondjack

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

This code will programmatically link to a backend. I have a modified
version of it that I use to check for an existing database in one location,
link to it, or link to a secondary location if the first is not found.

I'm not sure what type of backend you are using, but I use an mdb backend
and this code works perfectly.
--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery
 
J

J.J.

Just goes to show you that two heads are better than one. Both Daniel and
dymondjack pointed me to the same link. This seems to be exactly what I am
looking for. Wow, there is a fair bit of code to waltz through. And, yes, it
is a mdb backend.
I am going to go through it and see how I make out. At first glance, I
don't think I need all of it as I want to limit the end user's control and as
the backend is either on the server when logged on or, if not, the user is
out in the field so the local replica is used. There would be little reason
to set up unecessary input controls.

I'll keep you posted. Very much appreciated, both of you
 
D

dymondjack

When I re-did mine I commented out all of the msgbox's (I believe its only
the two in the beginning and one at the end that says that the tables were
relinked), and if I remember correctly, the only other part to change was
setting strNewPath to and If/Else statement. The function runs seamlessly
(less than one second run off a startup form) and no user intevention is
required. Don't quote me on strNewPath being the only variable to set, but
I'm *almost* positive that it was all that was required.

Definately a nice bit of code.

--
Jack Leach
www.tristatemachine.com

- "A designer knows he has reached perfection not when there is nothing left
to add, but when there is nothing left to take away." - Antoine De Saint
Exupery
 
J

J.J.

Thank you, once again, Jack.
I just printed the code sample off as I want to try and follow what is
actually going on. To be completely honest, I have a rough idea what is
happening but the code specifics - that'll take a bit more doing. No wonder
I couldn't figure it out. I expected four or five lines of code.
Yes, we're on the same page. I want to do exacly what you did: cut out the
user messages (that can only bound to cause grief) and create a simple
IF/Else statement that sets the strNewPath variable.
 
J

J.J.

Yup, got it working finally. Had a couple of bumps to overcome as I rewrote
a bit of it. TX
 

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