| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
does DAO.FindFirst use table indexes?
I have been using the DAO.FindFirst function in order to find records in my database but it seems to be very slow. I am confused because it seems to perform at the same speed regardless of the indexes on my table.
That is... Code:
rs.FindFirst (tape = 160 and ffid = 32451 and sline = 2286) Is this to be expected? Or is something strange going on? |
| Sponsored Links |
|
#2
|
||||
|
||||
|
Re: does DAO.FindFirst use table indexes?
if you do this often then you need an INDEX including those three fields.
then access will decide it can search using that index. If not, it has to search every record (probably in PK order) testing every record until it finds a match or gets to eof. That is why it is slow. ------------ Seek is optimised, becasue you tell it which index to use, but seek cannot be used on a linked table. (although there are wrok rounds for this)
__________________
Dave (Male!) Gemma was my dog if this helped, please click the scales at the top right of this posting. Many thanks. |
|
#3
|
|||
|
|||
|
Re: does DAO.FindFirst use table indexes?
As I said before, I tried defining an index for those three fields and it did not speed up my DAO.RecordSet.FindFirst function at all. This is strange I think??
However, I tried it again using DAO.RecordSet.Seek and an appropriate index. This time it worked wonderfully. So problem solved. Thanks. |
|
#4
|
|||
|
|||
|
Re: does DAO.FindFirst use table indexes?
A snippet of code for future forum readers:
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("RawShot", dbOpenTable)
' index UniqReq(jd, sline) is defined in my access table
rs.Index = "UniqRec"
' ... define variables jd and sline
rs.Seek "=", jd, sline
' ... do something ...
rs.Close
|
|
#5
|
|||
|
|||
|
Re: does DAO.FindFirst use table indexes?
Quote:
Quote:
|
|
#6
|
|||
|
|||
|
Re: does DAO.FindFirst use table indexes?
Yes I did see that warning... but lucky for me, I'm not working on a linked table.
I will keep it in mind for the future though. Thanks. |
|
#7
|
||||
|
||||
|
Re: does DAO.FindFirst use table indexes?
By the sound of it you are not using a linked table, this suggests that your database is not split. Even if the system is a simgle user system it is always best to have a FE/BE setup.
Because you commented on the speed - or lack of it - also suggests your are dealing with a table with a large amount of records, this is another indication that your setup is wrong.
__________________
David Crake www.xcraftlimited.co.uk The Home of Simple Software Solutions. O/S Windows XP (SP3) & Windows 7 64bit Access 2003 (version 11.0) Access 2007 (version 12.0) Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed. |
|
#8
|
|||
|
|||
|
Re: does DAO.FindFirst use table indexes?
Well... one step at a time.
If you have any ideas about why FindFirst would not be utelizing my table indexes that would be helpful. |
|
#9
|
||||
|
||||
|
Re: does DAO.FindFirst use table indexes?
Access decides its own method for using searches - I dont think you can force it to use a particular index in find first operations, as you can with a seek method
but what are you searching - a table or a query? if you use a query for your recordset, sorted by those 3 fields (instead of searching the table)- then it may work a lot better. and indeed if you expect to find just a single record then design your query to just return the 1 record. Then if the rs count is 0, it wasnt found - if its 1, it was found. there are many ways to skin this cat.
__________________
Dave (Male!) Gemma was my dog if this helped, please click the scales at the top right of this posting. Many thanks. |
| Sponsored Links |
![]() |
| Tags |
| dao, dao.findfirst, indexed field, indexes |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help in automatic updating database from xml | pushkar1986 | Modules & VBA | 5 | 08-31-2009 07:40 PM |
| Automatically Adding a Record from a primary table to a secondary table | VictorG | Tables | 5 | 08-24-2009 10:47 AM |
| In a database, how can I export record from one table to another? (w/follow-up qus) | 1308057 | Tables | 1 | 07-29-2008 06:41 AM |
| Indexes | WindSailor | Theory and practice of database design | 4 | 08-23-2006 10:30 PM |
| Need some suggestions on table layouts | chad101 | Tables | 16 | 01-08-2006 12:01 PM |