Re: Using Objects from another database
- From: engles@xxxxxxxxxxxx
- Date: 26 Apr 2007 14:23:16 -0700
On Apr 26, 9:20 am, Josetta <Jose...@xxxxxxxxxxxx> wrote:
Thanks for your reply. Hmm...this works fine with tables and I am
using this to make sure all my tables are linked properly. What I
need is to have this functionality with forms, reports and queries.
On Apr 26, 12:37 am, eng...@xxxxxxxxxxxx wrote:
On Apr 24, 5:40 pm, Josetta <Jose...@xxxxxxxxxxxx> wrote:
I searched around a little bit, but didn't come up with the answer to
this question, but somewhere in the back of my mind, I think this can
be done...
Let's say we have two different company functions: Sales and
Operations
The Operations database is considered the "main" one...we are using
this daily and it works very well.
I've now created a new database, which basically tracks prospects and
manages clients and their ongoing projects, which is now considered a
"sales" function.
Because we're having sales followup with clients as well, I'd like the
forms, reports, and code regarding the projects to be exactly the same
in the new sales db as it is in the old db.
Maintenance is a nightmare on all this already.
Is there a way to NOT import, but have the forms, reports, etc. be
exactly the same in both databases (like a reference, I guess), so
that I only need to maintain one of them. In other words, if I make a
change to the form or report or code in the main database, that change
is reflected in the new database.
This can be done, right? I wanna say you do almost like an Add-in
thing, right? How can I get this to work? Any ideas?
Thanks!
Josetta
I do this particular thing all the time. I don't use add-ins for this
particular functionality. Basically, keep the same front-end for all
back-ends and let the user switch backend databases (how you select
the new one is up to you. I use the common file dialog myself
usually), then cycle thru the tabledefs to define the new path to each
linked table. Here is a code snippet (this assumes an Access back-end
database):
For Each tdf In db.TableDefs
' If connect is blank, its not an Linked table
If Len(tdf.Connect) > 0 Then
tdf.Connect = ";DATABASE=" & varFileName
' The RefreshLink might fail if the new path isn't OK. So
trap errors inline.
On Error Resume Next
tdf.RefreshLink
I don't remember off-hand if I wrote that code from scratch or adapted
it from somewhere else (like Getz, Litwin, et. al.). You will
probably need to adapt to your needs, but this should show you the
basic idea.
-- Larry Engles
Access developer since day 1 of Access 1.0- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
I guess I was not detailed enough. The variable "varFileName" is
complete path for a backend database. It could be a different
database than is currently linked to. This then would then link to a
different backend. If you feed it the same path and file as the
existing backend, all you are doing is refreshing the link.
Hope this sheds light on the subject. Since the front-end (the mdb
file with the forms, reports, queries, etc.) does not change, you are
using the exact same front-end to re-link to mulitple backends.
-- Larry Engles
Access developer since day 1 of Access 1.0
.
- References:
- Using Objects from another database
- From: Josetta
- Re: Using Objects from another database
- From: engles
- Re: Using Objects from another database
- From: Josetta
- Using Objects from another database
- Prev by Date: Re: consignment problem
- Next by Date: Re: Delete record
- Previous by thread: Re: Using Objects from another database
- Next by thread: Re: Using Objects from another database
- Index(es):
Relevant Pages
|