Article ID: 131829
Article Last Modified on 1/19/2007
Option Explicit
Sub Seek_Attached_Table (Tablename$, Indexname$, SearchValue)
Dim db As Database
Dim t As TableDef
Dim rs As Recordset
Dim dbpath$, SourceTable$
On Error GoTo SA_Errors
Set db = dbengine(0)(0)
dbpath = Mid(db(Tablename$).connect, InStr(1, _
db(Tablename$).connect, "=") + 1)
If dbpath = "" Then MsgBox "You've chosen a table already in the _
current database", 64, "": Exit Sub
SourceTable = db(Tablename).sourcetablename
Set db = dbengine(0).OpenDatabase(dbpath)
Set rs = db.OpenRecordset(SourceTable, db_open_Table)
rs.index = Indexname
rs.Seek "=", SearchValue
If Not rs.nomatch Then
MsgBox "Found It!", 64
Else
MsgBox "Not Found", 64
End If
rs.Close
db.Close
Exit Sub
SA_Errors:
MsgBox Error, 16, CStr(Err)
Exit Sub
End Sub
Seek_Attached_Table "Orders","PrimaryKey",11000
Additional query words: how to
Keywords: kbhowto kbprogramming KB131829