Solved

access replace DLookup with SQL

Posted on 2010-08-16
5
552 Views
Last Modified: 2012-05-10
I have a calendar that puts total capacity numbers each day.  I use DLookups to calculate the capacity for each day - it is very slow.  I would like to use a sql query in hopes of speeding it up.  I currently have:

Cap2 = DLookup("[Qty]", "qryFrCapCalOpen", "[CompDate] = #" & Me.txtDay2 & "#")
Cap3 = DLookup("[Qty]", "qryFrCapCalOpen", "[CompDate] = #" & Me.txtDay3 & "#")
Cap4 = DLookup("[Qty]", "qryFrCapCalOpen", "[CompDate] = #" & Me.txtDay4 & "#")  
.....etc.

I am not sure how to proceed with the VBA code.

Any suggestions?

Thanks for your help.
0
Comment
Question by:johnmadigan
5 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33445465
Changing to query form still requires the query to go through and collect the data for each of the days being shown.
Do you have an index on table qryFrCapCalOpen column [CompDate] ?
0
 
LVL 18

Expert Comment

by:p912s
ID: 33447939
I'm guessing you're already using a query because the table name in your expression is qryFrCapCalOpen. Do the tables that qryFrCapCalOpen is pulling from have indexes?




0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 33449567
You could use a query, but then you would need a way to pass the query result to the form.
The added code to do this (Using a Recordset would be one way) would probably eat up more resources.

Speed is relative.
If your dlookup is searching a huge table, then this may never be "Fast", no matter what the technology...

JeffCoachman
0
 
LVL 26

Expert Comment

by:jerryb30
ID: 33471810
Making a temp table from the results of qryFrCapCalOpen might speed things up, especially if the query is itself complex.  
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34469397
Thanks, but please review jerryb30's suggestion.
What he posted is about the only way to increase the "Perceived" speed of a query...

JeffCoachman
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now