[mso] Re: Access 2002: Relative Table Links?

  • From: Cathy.Evans@xxxxxxxxx
  • To: mso@xxxxxxxxxxxxx
  • Date: Tue, 24 Aug 2004 11:02:44 -0400

James, all . . . I'm reviving this thread, found new information that looks
promising, but not sure how to incorporate into solution.  A refresher is
that I'm looking to link tables programmatically so I can send front
end/back end databases to a variety of remote sites.  Just need a little
better understanding and a push in the right direction, thanks!


I found the following question/answer in Helen Feddema's Microsoft Access
Version 2002 Inside Out, Chapter 16 - Importing and Linking Data to Access.


My question is this: How would I adjust her code to either link, import or
export (if linking is not possible, I'll use automated import and/or
exports to resolve)


How do I incorporate either method mentioned below into actual working
code, adjust it to link instead of import, if possible.=A0 Where do I put my
table/database names, & where do I put the code?=A0 Appreciate any
assistance, thank you!


Question From Book:
Troubleshooting: I need to import from another database in the current
path, but I don't want to hard code the path because the database might be
moved


Answer From Book:
You can use the Split function (introduced in Access 2000) to get the path
of the current database, store it in a String variable, and use it with the
name of the source database. The following function returns the path of the
current database:
Function ExtractDBPath() As String
=A0 On=A0Error=A0GoTo=A0ErrorHandler
=A0=A0=A0=A0Dim=A0strFilePath=A0As=A0String
=A0=A0=A0=A0Dim=A0strFullDBName=A0As=A0String
=A0=A0=A0=A0Dim=A0strFileName=A0As=A0String
=A0=A0=A0=A0Dim=A0strFullPath()=A0As=A0String
=A0=A0=A0=A0Dim=A0strDBName=A0As=A0String
=A0=A0=A0=A0Dim=A0intUBound=A0As=A0Integer
=A0=A0=A0=A0'Extract=A0path=A0of=A0current=A0database.
=A0=A0=A0=A0Set=A0dbs=A0=3D=A0CurrentDb
=A0=A0=A0=A0strFullDBName=A0=3D=A0dbs.Name
=A0=A0=A0=A0strFullPath=A0=3D=A0Split(strFullDBName,=A0"\",=A0-1,=A0vbTextC=
ompare)
=A0=A0=A0=A0intUBound=A0=3D=A0UBound(strFullPath)
=A0=A0=A0=A0strDBName=A0=3D=A0strFullPath(intUBound)
=A0=A0=A0=A0strFilePath=A0=3D=A0Mid(dbs.Name,=A01,=A0Len(dbs.Name)=A0-=A0Le=
n(strDBName))
=A0=A0=A0=A0Debug.Print=A0"Database=A0path:=A0"=A0&=A0strFilePath
ErrorHandlerExit:
=A0=A0=A0=A0Exit=A0Function
ErrorHandler:

=A0=A0=A0=A0MsgBox=A0"Error=A0No:=A0"=A0&=A0Err.Number=A0&=A0";=A0Descripti=
on:=A0"=A0&=A0_
=A0=A0=A0=A0=A0=A0=A0=A0Err.Description
=A0=A0=A0=A0Resume=A0ErrorHandlerExit

End=A0Function

Alternatively, you can simply use the CurrentProject.Path property to get
the path of the current database. Just set a variable equal to this
property, and use it in your code:

strFilePath=A0=3D=A0CurrentProjectPath


                                                                           =
                             =20
                      James LaBorde                                        =
                             =20
                      <jlaborde@xxxxxxxxx      To: "'mso@xxxxxxxxxxxxx'" <m=
so@xxxxxxxxxxxxx>            =20
                      >                                                    =
                             =20
                      Sent by:                 cc:                         =
                             =20
                      mso-bounce@freelist                                  =
                             =20
                      s.org                    Subject:  [mso] Re: Access 2=
002: Relative Table Links?   =20
                      08/16/2004 04:31 PM         :VSMail mx2              =
                             =20
                      Please respond to                                    =
                             =20
                      mso                                                  =
                        .....=20
                                                                           =
                             =20
                                                                           =
                             =20




Cathy,

Are you looking for something 100% automatic or would you be averse to
having the user enter the path?

James

-----Original Message-----
From: Cathy.Evans@xxxxxxxxx [mailto:Cathy.Evans@xxxxxxxxx]
Sent: Monday, August 16, 2004 1:20 PM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Access 2002: Relative Table Links? :VSMail mx2


Is there a way to set up 'relative' table links to a database in the same
folder?  I have added a 'read only' version of the database used by sites
that has a very shortened menu where user can only view reports and open
forms.  However it will link to the main database tables for the reporting,
and I do not know the particulars on each site server/directory, they are
all set up slightly different.  I use below line of code in my forms table
that links to a relative directory for the forms, but can I do same with
the tables, and if so, how?  I'm coming up blank in any searches for
attempting this and hope it can be done.  Thank you, Cathy

 (example of relative link to Word documents)
 oApp.Documents.Add Template:=3DCurrentProject.Path & "\WordDoc\" &
strFileName





---------------------------------------------------------------------------=
--------------------------
The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential
and/or privileged material. If you are not the intended recipient=20
of this message you are hereby notified that any use, review,
retransmission, dissemination, distribution, reproduction or any
action taken in reliance upon this message is prohibited. If you=20
received this in error, please contact the sender and delete the=20
material from any computer.  Any views expressed in this message
are those of the individual sender and may not necessarily reflect=20
the views of the company. =20
---------------------------------------------------------------------------=
----------------------------

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: