Solved

Alternative to DLOOKUP please

Posted on 2014-02-09
3
684 Views
Last Modified: 2014-02-10
Running my access file as .ADP against SQL Server 2008

Have some old code using DLOOKUP

ReqPickupTime = DLookup("[ReqPickupTime]", "[qrySwiftJobs]", "[SwiftTitle] = '" & Me.[cmbSwiftSelect] & "'")
CalledInBy = DLookup("[CalledInBy]", "[qrySwiftJobs]", "[SwiftTitle] = '" & Me.[cmbSwiftSelect] & "'")
FromYourName = DLookup("[FromYourName]", "[qrySwiftJobs]", "[SwiftTitle] = '" & Me.[cmbSwiftSelect] & "'")
PhoneNo = DLookup("[PhoneNo]", "[qrySwiftJobs]", "[SwiftTitle] = '" & Me.[cmbSwiftSelect] & "'")
CompanyName = DLookup("[CompanyName]", "[qrySwiftJobs]", "[SwiftTitle] = '" & Me.[cmbSwiftSelect] & "'")

Open in new window


and this goes on for about 30 more controls...


SO qrySwiftJobs I thought would speed things up on the entire jobs table apx 300,000 records.

Need some ideas
0
Comment
Question by:Dale Massicotte
3 Comments
 
LVL 10

Accepted Solution

by:
Gozreh earned 480 total points
ID: 39846360
I'm not sure whats your question, Please explain more whats your problem with using the dlookup ?
But instead of the dlookup you can open a recordset and then fill in all fields.
   Dim rs As DAO.Recordset
   Set rs = CurrentDb.OpenRecordset("SELECT * FROM qrySwiftJobs WHERE [SwiftTitle] = '" & Me.[cmbSwiftSelect] & "'", dbOpenSnapshot, dbReadOnly)
   With rs
      ReqPickupTime = ![ReqPickupTime]
      CalledInBy = ![CalledInBy]
      FromYourName = ![FromYourName]
      PhoneNo = ![PhoneNo]
      CompanyName = ![CompanyName]
   End With
   Set rs = Nothing

Open in new window

0
 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 20 total points
ID: 39846924
DLOOKUP will be very slow in this instance because it has to run the query and the Where clause for each of those controls.

Agree with Gozreh that you should be opening up a recordset, then just run down the list and apply those values to your controls.

I have not used an ADP, are you not able to create bound forms with the ADP?
0
 

Author Comment

by:Dale Massicotte
ID: 39847415
Thank you experts...this is what I needed.  I just have to modify the code for ADODB recordsets.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

777 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