Solved

access replace DLookup with SQL

Posted on 2010-08-16
5
600 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

690 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