You sound anxious to get started rewriting your app with ADO. Don't you like
DAO? A word of advice: most things we use either library for have
equivalents, so unless there's functionality that ADO has that DAO doesn't
have, don't spend time on a rewrite on a functional db.
You can use the seek method on a linked table if you use a recordset object
that's opened on the linked table's database, not the current db. Example:
Public Function linkedTblRS(strTableName As String) As DAO.Recordset
On Error GoTo link_Err
Dim db As Database
Dim strDBName As String
strDBName = Mid(CurrentDb.TableDefs(strTableName).Connect, 11)
Set db = DBEngine.Workspaces(0).OpenDatabase(strDBName, False, False)
Set linkedTblRS = db.OpenRecordset(strTableName, dbOpenTable)
link_Exit:
Set db = Nothing
Exit Function
link_Err:
MsgBox Err.Number & vbCrLf & Err.Description
Err.Clear
Resume link_Exit
End Function
Call the above function when you need to use seek on a linked table. Like
this:
Public Function seekInLinkedTbl()
On Error GoTo seek_Err
Dim rs As DAO.Recordset
Dim varBookmark As Variant
Dim strLookFor As String
strLookFor = "Grapes of Wrath"
Set rs = linkedTblRS("tblBooks")
rs.Index = "PrimaryKey"
varBookmark = rs.Bookmark
rs.Seek "=", strLookFor
If rs.NoMatch Then
rs.Bookmark = varBookmark
MsgBox "Not found"
Else
MsgBox "Found " & strLookFor
End If
seek_Exit:
Set rs = Nothing
Exit Function
seek_Err:
MsgBox Err.Number & vbCrLf & Err.Description
Err.Clear
Resume seek_Exit
End Function
Chris
Microsoft MVP
Indeed, tblSaldos is a linked table. But I need this DB_OPEN_TABLE parameter
in many cases, together with an indexed field and the .seek method.
It will be quit complicated to convert all this code, but maybe there are no
alternatives?
Is tblSaldos now a linked table? It's probably crashing because it's getting
an unhandled runtime error when it tries to open the recordset as a table
[quoted text clipped - 37 lines]
Define "won't work". What error message do you get?