Jim Dettman
jimdettman at verizon.net
Tue May 10 08:46:41 CDT 2011
Darryl, All the Domain functions are really encapsulated SQL statements, which can be used where an expression is allowed, but an SQL statement is not. Because of that, it also means they should not ever be used in a SQL statement. The simple reason being is that the query optimizer cannot optimize them and since they represent an SQL statement anyway, you should be using the appropriate Join(s) and SQL statements. As for them always being slower, that is not the case. A Dlookup() for example can be as fast as other methods. However it is inefficient to do something like this: =Dlookup("[FirstName]","tblEmployee","[EmployeeID] = " & lngEmployeeID) =Dlookup("[LastName]","tblEmployee","[EmployeeID] = " & lngEmployeeID) =Dlookup("[MiddleName]","tblEmployee","[EmployeeID] = " & lngEmployeeID) If your fetching anything more then a field or two, your far better off to open a record set, fetch the record, and then have access to the entire record. Jim. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darryl Collins Sent: Monday, May 09, 2011 08:18 PM To: Access Developers discussion and problem solving Subject: [AccessD] Whilst on DLOOKUPs.... ____________________________________________________________________________ ___________ Note: This e-mail is subject to the disclaimer contained at the bottom of this message. ____________________________________________________________________________ ___________ Hi Folks, A database I have been given to work on uses a lot of DLOOKUPs (hundreds). Personally I don't like them much and prefer to write SELECT SQL statements or a neat little function to get values back from a table. I do this as these methods are more flexible and easier to read and debug compated to DLOOKUP. Using recordsets to get data also seems to be as fast as using DLOOKUP, although given the speed of today's processors I am not sure it is something a human would notice anyway. The DLOOKUP is a short piece of code, but harder to read, or at least I find it harder (often because the DLOOKUP is a long string make up of variables and often extent outside the visibile VBE window. I recall reading somewhere that there are issues when using a lot of DLOOKUPs, of course I could dreaming as well. I know Allan Browne has identified some issues, these alone would make me nervous about using DLOOKUP so I am happy not to bother with them. <<http://allenbrowne.com/ser-42.html>> However, curious to know what your opinion is of them. Do I have an attitude problem as they fast, useful and reliable or is my reluctance worthwhile as DLOOKUP is something best to be used sparingly and with some caution? Cheers Darryl. _____________________________________ Darryl Collins | Business Analyst Database Developer Retail Business Insurance Insurance Australia Group (IAG) Level 2, 181 Williams St, Melbourne, 3000 - Australia Ph: + 61 3 9916 3926 Mobile: + 61 418 381 548 ____________________________________________________________________________ ___________ The information transmitted in this message and its attachments (if any) is intended only for the person or entity to which it is addressed. The message may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. If you have received this in error, please contact the sender and delete this e-mail and associated material from any computer. The intended recipient of this e-mail may only use, reproduce, disclose or distribute the information contained in this e-mail and any attached files, with the permission of the sender. This message has been scanned for viruses. ____________________________________________________________________________ ___________ -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com