I have two tables that may contain information a user is looking for. One is the “active” table; the other is an “archived” table. Information gets archived periodically, but sometimes may need to be brought back to the active table. Users generally access the active table (by entering a Customer ID in a form), but if they enter a customer ID which does not exist in the active table, I use a DLookup function to check the archived table. If it exists there, they’re given the option of viewing the archived record and/or bringing it back to the active table. The problem is that, over time, the archived table is getting huge and the DLookup is getting slow. Is there a method of looking the customer ID up in the archived table that is faster than DLookup? I’ve read that opening a recordset is faster than DLookup. Is that true? How should I handle this situation? The database is split – the data physically resides in a separate database on the server.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Need something faster than DLookup
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Need something faster than DLookup
- This topic has 19 replies, 7 voices, and was last updated 15 years ago.
Viewing 9 reply threadsAuthorReplies-
WSsquenson
AskWoody Lounger -
WSodeus
AskWoody Lounger -
WSLarryEngles
AskWoody Lounger
-
-
WSAndrewKKWalker
AskWoody Lounger -
WSMarkLiquorman
AskWoody LoungerApril 27, 2010 at 1:56 pm #1220894I have two tables that may contain information a user is looking for. One is the “active” table; the other is an “archived” table. Information gets archived periodically, but sometimes may need to be brought back to the active table. Users generally access the active table (by entering a Customer ID in a form), but if they enter a customer ID which does not exist in the active table, I use a DLookup function to check the archived table. If it exists there, they’re given the option of viewing the archived record and/or bringing it back to the active table. The problem is that, over time, the archived table is getting huge and the DLookup is getting slow. Is there a method of looking the customer ID up in the archived table that is faster than DLookup? I’ve read that opening a recordset is faster than DLookup. Is that true? How should I handle this situation? The database is split – the data physically resides in a separate database on the server.
For a single lookup like that, I don’t think opening a recordset is any faster. I trust you have compacted the db with the archived table?
I’m assuming this is a front-end/back-end situation? If so, you can open the the archive table directly (not as a linked table), and then use SEEK to find the record. This is as fast as it gets.
-
WSjswedlund
AskWoody LoungerApril 28, 2010 at 10:00 am #1221016For a single lookup like that, I don’t think opening a recordset is any faster. I trust you have compacted the db with the archived table?
I’m assuming this is a front-end/back-end situation? If so, you can open the the archive table directly (not as a linked table), and then use SEEK to find the record. This is as fast as it gets.
Mark,
What is the best way to do this, i.e., open the table directly? Use the IN external file clause in a query? Use a DAO Workspace? Other?Thanks
-
WSMarkLiquorman
AskWoody LoungerApril 28, 2010 at 7:21 pm #1221110Mark,
What is the best way to do this, i.e., open the table directly? Use the IN external file clause in a query? Use a DAO Workspace? Other?Thanks
It’s been awhile, and I’m answering this remotely (I’m not at a computer where I can check syntax). Basically, it would be:
dim db as dao.database.
dim rs as dao.recordsetset db = … (it is here you’d directly reference the backend, can’t remember syntax)
set rs = db.Openrecordset(“tablename”,dbOpenTable)I’d make these Public variables, so they are kept open (otherwise, you lose speed advantage). then when you need it:
rs.Seek …
You’ll have to use Help to fill-in the blanks. Like I said, it has been awhile.
-
-
-
WSjswedlund
AskWoody Lounger -
WSMarkLiquorman
AskWoody LoungerApril 29, 2010 at 6:27 pm #1221280Thanks, Mark.
I tested and see that this would work, but am wondering whether a query that uses the IN ‘BackEnd.mdb’ clause (as the recordset might work as well.
Yes, it probably will. The key is to define the recordset as public so you don’t have to constantly recreate it. That’s where you lose time.
-
WSjswedlund
AskWoody Lounger
-
-
-
WBell
AskWoody_MVPApril 29, 2010 at 5:17 pm #1221272Larry’s question with regard to what is large is very relevant – we do searches on table containing 4 million or more recors and get subsecond response time, but the table has to be indexed properly, and you need a robust server that can keep the data in memory. (We link to a SQL Server backend.)
-
WSodeus
AskWoody LoungerMay 2, 2010 at 9:29 am #1221631Thanks for everyone’s feedback. I don’t have 4 million records – more like 500,000 (and growing) – but I don’t have a “robust server”. This is a front-end/back-end situation, but I’m only using Access tables as my backend not SQL server, so I’m hampered by speed this way and the fact that the network is slow. I’ll re-write the code to open a recordset directly as suggested by Mark and see if that speeds things up. Thanks for your help.
As an aside, Mark recommends “Define the recordset as Public”…..is there an issue with keeping a recordset open? In the recesses of my mind, I remember being told “get in, get out” when dealing with data sets. “open the database, get your data and close the connection”. Am I locking the records and leaving the recordset open by defining it as public? Will this be setting myself up for corruption or frustration by other users trying to access the same records moments later? I’ll admit my schooling was several years ago and maybe things have changed….
-
WSLarryEngles
AskWoody LoungerMay 2, 2010 at 11:21 am #1221644Thanks for everyone’s feedback. I don’t have 4 million records – more like 500,000 (and growing) – but I don’t have a “robust server”. This is a front-end/back-end situation, but I’m only using Access tables as my backend not SQL server, so I’m hampered by speed this way and the fact that the network is slow.
I still think you would be best served by a simple query in code (e.g. Select * from tablename WHERE criteria here; Remember, the jet engine is optimized for queries.
I just ran a test against a 1.6GB table with 1.5+ million rows. The table is a linked Access table. With a query, selecting a specific row (against an indexed field) took well under 1 second. The linked table is on the same PC, so it is not slowed down by network access – which can be a significant slowdown. A slow network is even more reason to select a single row (or the minimum number of rows you need). I suspect (without testing) that having an open recordset that you use seeks on would be slower. I could be mistaken on that, but don’t think so. I’d be interested in a comparison. Come to think of it, I might do that and let you know if you are interested. Let me know. It would not take long to test.
Let us know how it goes.
-
WSMarkLiquorman
AskWoody LoungerMay 2, 2010 at 6:27 pm #1221687Thanks for everyone’s feedback. I don’t have 4 million records – more like 500,000 (and growing) – but I don’t have a “robust server”. This is a front-end/back-end situation, but I’m only using Access tables as my backend not SQL server, so I’m hampered by speed this way and the fact that the network is slow. I’ll re-write the code to open a recordset directly as suggested by Mark and see if that speeds things up. Thanks for your help.
As an aside, Mark recommends “Define the recordset as Public”…..is there an issue with keeping a recordset open? In the recesses of my mind, I remember being told “get in, get out” when dealing with data sets. “open the database, get your data and close the connection”. Am I locking the records and leaving the recordset open by defining it as public? Will this be setting myself up for corruption or frustration by other users trying to access the same records moments later? I’ll admit my schooling was several years ago and maybe things have changed….
You want to minimize the # of recordsets you have open, as it takes up memory. But the performance benefits of holding open a recordset connected directly to the backend outweighs the memory penalty of keeping it open.
-
-
WSodeus
AskWoody LoungerMay 2, 2010 at 6:57 pm #1221688Mark – thanks for clarifying what happens with multiple recordsets open. It makes sense that it uses memory to leave it open, and it also makes sense that it would be faster if it was already open! There’s no issue with selecting a particular record when opening the recordset? Will Access lock that record until the recordset is closed again?
Larry – I would be interested in a comparison between the seek and the regular query (since it sounds to me that you’d like to test that! ) I have a lot of work to do with datasets in this project, so I want to optimize my interaction with the data. The data has to be split for security reasons – I just wish I had a faster network. -
WSLarryEngles
AskWoody LoungerMay 2, 2010 at 7:28 pm #1221695Larry – I would be interested in a comparison between the seek and the regular query (since it sounds to me that you’d like to test that! ) I have a lot of work to do with datasets in this project, so I want to optimize my interaction with the data. The data has to be split for security reasons – I just wish I had a faster network.
I’ll try to get to this in the next day. I’m pretty sure I can.
-
WSMarkLiquorman
AskWoody LoungerMay 3, 2010 at 10:07 am #1221759Mark – thanks for clarifying what happens with multiple recordsets open. It makes sense that it uses memory to leave it open, and it also makes sense that it would be faster if it was already open! There’s no issue with selecting a particular record when opening the recordset? Will Access lock that record until the recordset is closed again?
Merely looking at a record doesn’t lock it.
-
-
WSLarryEngles
AskWoody LoungerMay 3, 2010 at 11:29 am #1221767A very interesting result – not exactly what I had expected, but good anyway! I set up random lookups (there was a unique key on the table and I searched on it – 4 fields). I set up a random lookup (via separate tables which held only parts of the unique key). Then I used three different methods (and 3 completely separate runs, each using only one method of lookup). Here are the results (ms = milliseconds): There were over 1.6 million rows in an attached table. Since I was doing all this work anyway, I decided to at least look at the .findfirst method on an open recordset. The results on that were even worse than I expected.
FindFirst method:
-
[*]Number Lookups: 10
[*]Min Ms: 655
[*]Max ms: 4368
[*]Avg ms: 2128Query method:
-
[*]Number Lookups: 1000
[*]Min ms: 0
[*]Max ms: 46
[*]Avg ms: 4Seek method:
-
[*]Number Lookups: 1000
[*]Min ms: 0
[*]Max ms: 15
[*]Avg ms: .05I must admit I’m surprised by how much faster the seek is. It is definitely more complicated to use, but would be worth using if one were looking up thousands of times or more (for 1000 lookups, the total time is 4 seconds vs .05 seconds). I think I’ve only used a seek one time myself.
From what I can tell on the original problem description, I’d guess that the user will not be able to tell the difference between a query implementation and a .seek implementation. My inclination would be to implement with a query and see how it goes. If it is too slow, then move to a .seek and see if it improves response any, but if you have a slow network, I’m not sure you’ll see much improvement. I just don’t know how a slow network affects the response times (well, we all know it does slow it down
). It could be that the lookup time is just in the noise.
-
WSodeus
AskWoody LoungerMay 3, 2010 at 1:30 pm #1221777That’s really helpful, Larry! I’ll be using a seek as often as possible from now on! You’re right about the network, though. I’ll have to talk to the hardware guys and see what can be done about getting some more speed or bandwidth or something.
Mark: Thanks for clarifying that records aren’t locked when a record is only viewed.
Viewing 9 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
MS Office 365 Home on MAC
by
MickIver
3 hours ago -
search by picture an not all that’s cracked up to be (Awaiting moderation)
by
Dru Fuksa
4 hours, 38 minutes ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
11 hours, 43 minutes ago -
Flash Drive Eject Error for Still In Use
by
J9438
13 hours, 16 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
1 day, 6 hours ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
1 day, 6 hours ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
10 hours, 15 minutes ago -
Migrate off MS365 to Apple Products
by
dmt_3904
11 hours, 4 minutes ago -
Login screen icon
by
CWBillow
1 hour, 26 minutes ago -
AI coming to everything
by
Susan Bradley
9 hours, 3 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
1 day, 22 hours ago -
No Screen TurnOff???
by
CWBillow
1 day, 22 hours ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
1 day, 23 hours ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
2 days, 10 hours ago -
How well does your browser block trackers?
by
n0ads
1 day, 21 hours ago -
You can’t handle me
by
Susan Bradley
21 hours, 2 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
1 day, 13 hours ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
2 days, 22 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
2 days, 1 hour ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
2 days, 22 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
2 days, 22 hours ago -
Lumma malware takedown
by
EyesOnWindows
2 days, 10 hours ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
3 days, 7 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
3 days, 7 hours ago -
Meet Gemini in Chrome
by
Alex5723
3 days, 11 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
3 days, 11 hours ago -
Trump signs Take It Down Act
by
Alex5723
3 days, 19 hours ago -
Do you have a maintenance window?
by
Susan Bradley
2 days ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
2 days, 21 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
3 days, 22 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.