PDA

View Full Version : How to replace multiple DLookups with stored procs in SQL



sowjanya2008
04-10-2012, 10:22 AM
I am moving access qrys to stored procs in sql server. Any recomendations on how i should handle the DLOOKUP function ?
Any help on how should I replace all the below DLookups with single stored proc with output parameters.

Private Sub Borrower_Exit(Cancel As Integer)
txtBorrowerCo = DLookup("CompanyNo", "LenderBorrower", "Name= Forms!frmLoanCreation!Borrower")
txtBorrowerID = DLookup("ID", "LenderBorrower", "Name= Forms!frmLoanCreation!Borrower")
txtBorrowerLocation = DLookup("Location", "LenderBorrower", "Name= Forms!frmLoanCreation!Borrower")
txtBorrowerSignee = DLookup("Signee", "LenderBorrower", "Name= Forms!frmLoanCreation!Borrower") '**** 991020
txtBorrowerTitle = DLookup("SigneeTitle", "LenderBorrower", "Name= Forms!frmLoanCreation!Borrower") '**** 991020
Child14.Requery
End Sub

Also, could you please explain what Requery does?
In 'Child14.Requery', Child14 refers to a gird

hansup
04-11-2012, 09:27 AM
It's unclear why you want to use a stored procedure to replace DLookup(). Seems to me those could continue to work as written with LenderBorrower as a link to the SQL Server table.

Or, since you're pulling 5 values from LenderBorrower all based on the same condition, you could pull them from a recordset based on a query which returns CompanyNo, ID, Location, Signee, and SigneeTitle for a Name which matches Forms!frmLoanCreation!Borrower

Look at the Access help topic for the Requery method to find out what it does.