Amy said:
I have a dialog box that is supposed to find records in a table that match
records in another table and update one of three dates based on the selection
made in the dialog. I'm using the Seek method in VBA. However, when I split
the database, this no longer works, as Seek doesn't work for linked tables.
Is there some method that has the same effect on a linked table? If so, how
would I apply it?
Here is code I have been using for years for DAO linked tables:
'----------------------------------------------------------------------------------
'Open_For_Seek
'
'Purpose:
' This service opens a linked table.
'
'Parameters:
' TableName - the name of the table to be opened
'
'Rev Num Date Author Description of Change
'------- -------- ------
-----------------------------------------------------
' 001 03/01/99 ash Code Courtesy of Michael Kaplan
'----------------------------------------------------------------------------------
Public Function Open_For_Seek(TableName As String) As DAO.Recordset
On Error Resume Next
Dim dbCur As DAO.Database
Dim dbLink As DAO.Database
Dim stDbName As String
Set dbCur = CurrentDb
stDbName = Mid$(dbCur.TableDefs(TableName).Connect, 11)
Set dbCur = Nothing
Set dbLink = DBEngine(0).OpenDatabase(stDbName)
Set Open_For_Seek = dbLink.OpenRecordset(TableName, dbOpenTable)
' Do not close dbLink or the rs may suffer for it
Set dbLink = Nothing
End Function
'--------------------------------------------------------------------
put this in a module
use it like this:
dim rst as dao.recordset
set rst = open_for_seek("your linked table name")