SEEK on a linked table with DAO or ADO

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

SEEK on a linked table with DAO or ADO

Post by sal21 »

Important... :scratch:
I need to use a seek metod on a linked table in \\myserver\mydir\MYDATABASE.Mdb
Tks.

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SEEK on a linked table with DAO or ADO

Post by HansV »

I don't think you can use Seek with a linked table.

You'll have to open a recordset on the source table, not on the linked table.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: SEEK on a linked table with DAO or ADO

Post by sal21 »

HansV wrote:I don't think you can use Seek with a linked table.

You'll have to open a recordset on the source table, not on the linked table.
Wath you think about:

Code: Select all

Public Sub Open_For_Seek()

    stDbName = "\\rom\work$\FS07\GO\DATABASE\TUTTI.MDB"
    Set dbCur = Workspaces(0).OpenDatabase(stDbName)

    Set RST = DBEngine(0)(0)("TUTTI").OpenRecordset
    RST.Index = "RAPP"
 
End Sub

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SEEK on a linked table with DAO or ADO

Post by HansV »

Is \\rom\work$\FS07\GO\DATABASE\TUTTI.MDB the backend database that contains the actual table?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: SEEK on a linked table with DAO or ADO

Post by sal21 »

HansV wrote:Is \\rom\work$\FS07\GO\DATABASE\TUTTI.MDB the backend database that contains the actual table?
yes

TUTTI table

Note
Database and table have the same name, is a simple case:-)

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SEEK on a linked table with DAO or ADO

Post by HansV »

It should work if the table has an index named RAPP.
Otherwise, you can use the FindFirst method of the recordset. This will work with non-indexed fields too.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: SEEK on a linked table with DAO or ADO

Post by sal21 »

HansV wrote:It should work if the table has an index named RAPP.
Otherwise, you can use the FindFirst method of the recordset. This will work with non-indexed fields too.
but in term of time to find a value, is good seek or findfirst?

in other case if findfirst is false i need to check .Eof or ?

note:
in RAPP dont is possible duplicte values

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SEEK on a linked table with DAO or ADO

Post by HansV »

If you have an existing index on RAPP, you can use Seek.
In all situations, you can use FindFirst.

If Seek or FindFirst doesn't find a match, RST.NoMatch will be true.
Best wishes,
Hans