Solved

Alternative to DLOOKUP please

Posted on 2014-02-09
3
697 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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.

839 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