Microsoft KB Archive/188801

= ACC: Using Visual Basic to Hide a Link to an External Table =

Article ID: 188801

Article Last Modified on 1/23/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q188801



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
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.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. The 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.

Creating, Linking, and Hiding the Table
 Start Microsoft Access and open the sample database Northwind.mdb.  Create a module and type the following line in the Declarations section if it is not already there: Option Explicit   Type the following procedure: 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   To test this function, type the following line in the Debug window, and then press ENTER: ?MakeHiddenAttachedTable ("Solutions", "Examples", "New Table") A new hidden table named New Table that links the Examples table in the Solutions database is created. 

Delete the New Table Table
The following steps demonstrate how to use a Visual Basic for Applications procedure to delete a hidden linked table in the sample database Northwind.mdb:  Start Microsoft Access and open the sample database Northwind.mdb.</li>  Create a module and type the following line in the Declarations section if it is not already there: Option Explicit </li>  Type the following procedure: Function DeleteHiddenAttachedTable(strAttachedTableName As String)

Dim db As Database Set db = CurrentDb

db.TableDefs.Delete strAttachedTableName

End Function </li>  To test this function, type the following line in the Debug window, and then press ENTER: ?DeleteHiddenAttachedTable("New Table") The new hidden table, New Table, is deleted. </li></ol>

Additional query words: inf link attach attached

Keywords: kbhowto kbprogramming KB188801

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.