Using Seek Method in a linked table

G

Guest

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?
 
S

strive4peace

If you are using a recordset object, you can use FindFirst

rs.FindFirst "criteria"

If you are wanting to update the records in the other table,
you can use an update query instead of finding the record.
If you specify the relevant data structure, how the tables
are related, the control names on your form and which fields
they correspond to, we can help you further with the SQL to
accomplish this


Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
D

Duane Hookom

You can use Seek if you set the Database object to the remote mdb.

Dim db as DAO.Database
Set db = OpenDatabase("H:\Data\YourApp\AppData.MDB")

You can then use the seek method on a recordset created with the db.
 
A

Andy

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")
 
G

Guest

Would this function go in the database I'm working in or the database I'm
linking to?
 
T

Tim Ferguson

=?Utf-8?B?QW15IEUuIEJhZ2dvdHQ=?= <[email protected]>
wrote in
sorry to take the bits in your post out of order but..
I'm using the Seek method in VBA.

Why?? As its name suggests, seek is a method for moving round sequential
text files (as in dBase) -- since you are now using a database program it
might be an idea to use database techniques?
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.

This surely is a pure SQL problem; something along the line of

UPDATE MyTable
SET MyDate = SomeOtherDate
WHERE RecordID IN
( SELECT RecordID
FROM OtherTable
WHERE SomeCriterion = TRUE
)


B Wishes


Tim F
 
D

Duane Hookom

Seek is very powerful and efficient in a database. I used it in an
application where I had temporary, imported records in a very unnormalized
table which could contain a dynamic number of fields. I couldn't use SQL
since the fields weren't known. I tried various find methods since the
tables were linked. I changed the code to use the Seek method and a process
that had taken an hour to run was able to complete in less than 2 minutes.
 
T

Tim Ferguson

I used it in an
application where I had temporary, imported records in a very
unnormalized table which could contain a dynamic number of fields. I
couldn't use SQL since the fields weren't known.

It's alright: I'm not about to go on another Holy War!

Just to point out, though, that this description is of a file management
problem, not a database one... and that is exactly what I said Seek was for
<g>

All the best


Tim F
 
D

Duane Hookom

I guess I am not sure what you mean by "file management problem". I agree
that you shouldn't send in coding of recordsets and updates where SQL could
be used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top