Jump: Search:

Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access 2007/2010 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2010 (32 bit), 2007, 2003, 2002, 2000, and
Visual Basic 6.0!

Also available for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

 

 
Royalty free source code library modules for Microsoft Access, VB6, VBA, OfficeRoyalty free source code library modules for Microsoft Access, VB6, VBA, OfficeVBA and VB6 Source Code Library Download the free trial version of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA
Category: Database : Access/Jet
Description: Microsoft Access Jet databases and their objects (MDB and ACCDB database formats)

Class: CJetLinkedTables

Working with Microsoft Jet Linked tables using DAO

This class exposes methods and properties for working with Microsoft Jet Linked (attached) tables. Microsoft Jet provides a powerful mechanism for accessing external data sources. This technique, called "Linking" (or attaching in Access 2/Jet 2 terminology) allows you to create a permanent link to an external database or file. A variety of data sources are supported: - Microsoft Access/Jet databases - dBASE DBF files - Paradox DB files - FoxPro DBF files - Excel spreadsheets - HTML Import And Export - Text Files - Exchange data stores - ODBC data sources Links are useful because they make the external data source appear as a standard table in the database. This makes the management of data across disparate sources easy, and since links can cache structure information about the external data source, accessing the data is usually faster than opening the external data source each time.

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CJetLinkedTables class
Database Property Assigns a database variable to the class The Database property returns the DAO Database object of the database the class currently has open. This allows you to: 1.You can use the Database property to gain access to any of the properties and methods available for the database object that refers to the currently open database. For example, you can instantiate the class, call the OpenDB() method, and then use the class Database property to refer to any of the properties or methods that are applicable to the DAO Database object type. In the code below, we use this technique to display the version of database that the class has open by using the DAO Version property of the database object: Dim MyDB As CJetLinkedTables Set MyDB = New CJetLinkedTables MyDB.OpenDB "C:\NWIND.MDB, False, False" Debug.Print MyDB.Database.Version 2. If your code already has the database open, you can Set the class Database property to your database variable. In such a case, this is preferable to using the class OpenDB() method because only one instance of the database is open. Dim dbs As DAO.Database Dim MyDB As CJetLinkedTables Set dbs = DAO.DBEngine(0).OpenDatabase("C:\NWIND.MDB") Set MyDB = New CJetLinkedTables Set MyDB.Database = dbs
DatabasePassword Property Gets the database password used to open the database. This property only has a value if the OpenDB method was called and a password was specified. The property cannot 'extract' the database password used to open a database outside of the class.
OpenExclusive Property Returnsthe status of whether or not the database was opened by the class in exclusive mode. The value of this property only has meaning if the OpenDB method was called. This property cannot 'extract' the Exclusive setting of a database opened outside of the class.
OpenReadOnly Property Gets the status of whether or not the database was opened by the class in read-only mode. The value of this property only has meaning if the OpenDB method was called. This property cannot 'extract' the read-only setting of a database opened outside of the class.
Class_Terminate Terminate Code called when the class terminates
CloseDB Method Closes the current open database. Note that this only works if the class opened the database through the OpenDB() method. If the class has a database open that was passed to it through the Database property, or the OpenDB() method has not yet been called, this method silently fails.
CreateExchangeLink Method Creates a new link to the specified Exchange data source. Use this method to create a link in the specified database to a Microsoft Exchange data store such as an inbox, address book, or contact list. The value for the strFolderName parameter can be quite tricky--it needs to correspond to a node in the treeview that is visible when you have Exchange Inbox or Microsoft Outlook open. A typical connection string for an Exchange data source looks like this: Exchange 4.0;MAPILEVEL="Mailbox - Dave Jones|Inbox;TABLETYPE=0;DATABASE=C:\NWIND.MDB;Profile=Microsoft Outlook;PWD=topsecret For complete details on the valid settings for Exchange connection strings, search DAO online help for "Connect." NOTE: Sometimes installing Office, VB, or the Data Access Pack installs the Microsoft Exchange driver, but does not register the driver. This problem manifests itself with the "Could not find installable ISAM" error message when you try to link to an Exchange data source through DAO/Jet. To solve this problem, you must manually register the Exchange Driver. For more information, see the Microsoft Knowledgebase article #Q161173.
CreateISAMLink Method Creates a new table link to the specified data source. Supports all link types except Jet, ODBC and Exchange. Use this method to create a new table link in the specified database to any of the following data sources: - Paradox - Excel - DBase - FoxPro - Text - HTML
CreateJetLink Method Creates a new table link to a Jet table. Note that you can link a table with a new name by specifying the new name in the strTableName parameter. In such a case, the database with the link shows a table name different from the name of the table that it is linked to.
CreateODBCLink Method Creates a new table link to the specified ODBC data source. Use this method to create a link to a registered ODBC data source, such as a SQL Server or Oracle installation. To create and register ODBC data sources, use the ODBC Administrator available under the Windows Control Panel, or use the RegisterDatabase method of the DAO DBEngine object. The optional strDtabase, strUID and varPWD parameters override the DSN values. If you do not specify a value for one of the parameters, and the DSN does not have that value specified, the ODBC driver will prompt you for values.
DeleteAllLinks Method Deletes all linked tables in the current database. *Caution* This deletes ALL links in the current database without confirmation.
FailedLinkedTables Method Tests the links of all the linked tables to see if they are okay
GetLinkedPath Method Returns the linked path of the named table
GetLinkedType Method Returns the type of the named linked table
IsTableLinked Method Determines if the named table is a linked table
OpenDB Method Opens the named Access/Jet database. Before using the class, the class must be associated with a database. Use the OpenDB method to tell the class which database you want to use. This method opens the database using the options specified and keeps the database open until the class is de-instantiated. If you already have a database variable open and want to use this class, you can set the class Database property to an open DAO Database object variable. See the Database property of this class for more information.
RelinkTable Method Relink (attach) a table to a new database. This method only works with non-Exchange, non-ODBC table links. To relink Exchange or ODBC table links, you should delete and recreate the table links. The method accomplishes its task by setting the Connect property of the specified table's TableDef object to the new path. It then calls the RefreshLink method to force Jet to open the source database and table and establish the permanent link.
RelinkTables Method Relink all the linked (attached) tables to a new database. This method only works with non-Exchange, non-ODBC table links. To relink Exchange or ODBC table links, you should delete and recreate the table links. The method accomplishes its task by setting the Connect property of the specified table's TableDef object to the new path. It then calls the RefreshLink method to force Jet to open the source database and table and establish the permanent link.
TestLinkedTable Method Tests the validity of the specified linked table. Table links become broken when the database or directory that is linked to is moved, deleted, or renamed. Testing table links is not an easy operation because DAO does not expose a property that tells you whether or not the link is valid. The problem is further complicated because you can set an object variable to a linked table with a broken link, and no runtime error is generated. This is because Jet caches information about the table when the link is created. When you point an object variable to the link, the cached information is read, not the information from the actual source table. The only sure-fire way to test a link's validity is to try and get information from the underlying table that is not cached. To do this, this method turns off error handling and tries to get the name of the first field in this table. Since this information is not cached in the table link, Jet is forced to try and open the source table that the link points to. If the link is broken, a runtime error occurs. We trap this error and can determine that the link is broken.
TestLinkedTables Method Tests the links of all the Linked tables. This method works by iterating through all tables in the current open database. It checks the Connect property of each table to determine which tables are linked. For information on the technique for determining if links are valid, see the TestLinkedTable method.

Overview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources

Feedback

Contact Us  l   Web questions: Webmaster   l   Copyright © FMS, Inc., Vienna, Virginia
Celebrating our 26th Year of Software Excellence