[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 942
  • Last Modified:

Alternative to DLOOKUP please

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
Dale Massicotte
Asked:
Dale Massicotte
2 Solutions
 
GozrehCommented:
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
 
Dale FyeCommented:
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
 
Dale MassicotteAuthor Commented:
Thank you experts...this is what I needed.  I just have to modify the code for ADODB recordsets.
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now