ACC: Using Visual Basic to Hide a Link to an External TableID: Q188801
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article shows you how you can use Visual Basic for Applications to
link an external table but to hide the link on your local computer. You do
this by creating a new table, creating the link to the external table, and
then setting the hidden attribute of the newly created table to True.
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.aspThe following Visual Basic for Applications procedure use the sample database Northwind.mdb to create a new table (New Table); it then links the new table to an external table (the Examples table in the sample database Solutions.mdb); and finally, it sets the hidden attribute of the new table to True so that the table is hidden on the local computer.
Option Explicit
Function MakeHiddenAttachedTable(strDatabaseName As String, _
strTableName As String, strAttachedTableName As String)
Dim db As Database
Dim td As TableDef
Set db = CurrentDb
Set td = db.CreateTableDef(strAttachedTableName)
td.Connect = ";Database=" & strDatabaseName
td.SourceTableName = strTableName
db.TableDefs.Append td
td.Attributes = dbHiddenObject
Set td = Nothing
Set db = Nothing
End Function
?MakeHiddenAttachedTable ("Solutions", "Examples", "New Table")
A new hidden table named New Table that links the Examples table in the
Solutions database is created.
Option Explicit
Function DeleteHiddenAttachedTable(strAttachedTableName As String)
Dim db As Database
Set db = CurrentDb
db.TableDefs.Delete strAttachedTableName
End Function
?DeleteHiddenAttachedTable("New Table")
The new hidden table, New Table, is deleted.Additional query words: inf link attach attached
Keywords : kbdta AccCon TblHowto KbVBA
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 6, 1999