Open a separate ADO connection to the back-end database, and open the table directly instead of using the linked table. To see an example of how to do this, follow these steps:
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.
NOTE: The sample code in this article uses Microsoft ActiveX Data Objects. For this code to run properly, you must reference the Microsoft ActiveX Data Objects 2.x Library (where 2.x is 2.1 or later.) To do so, click
References on the
Tools menu in the Visual Basic Editor, and make sure that the
Microsoft ActiveX Data Objects 2.x Library check box is selected.
- Follow steps 1 through 7 in the "Steps to Reproduce Behavior section" later in this article.
- Type the following procedure within the new module:
Sub LinkTableSeek()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "C:\Program Files\Microsoft " _
& "Office\Office\Samples\Northwind.mdb"
.Open
End With
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = cn
.Source = "Customers"
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.Open Options:=adCmdTableDirect
.Index = "PrimaryKey"
.Seek "WOLZA"
If (Not .EOF And Not .BOF) Then
MsgBox rs.Fields("CompanyName").Value
Else
MsgBox "Record not found"
End If
.Close
End With
Set rs = Nothing
Set cn = Nothing
End Sub
- Follow steps 9 and 10 in the "Steps to Reproduce Behavior" section later in this article.
Note that you receive a message with the text "Wolski Zajazd," which is the company name of the CustomerID that the code was seeking.