?
Solved

access replace DLookup with SQL

Posted on 2010-08-16
5
Medium Priority
?
610 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

762 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