Results 1 to 2 of 2
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    Combining Dlookup function

    Is it possible to combine



    IsComp: DLookUp("Action_Complete","[Change Request]","CR_No = " & [Change Request].[CR_No] & " AND Sub_No<>0"
    SDate: DLookUp("[Date_Closed]","[Change Request]","CR_No= " & [CR_No] & " AND Sub_No=0"

    Since both reside in the [Change Request] table? or does the criteria have to be the same also?

    What would be the most efficient way of coding this. It slows down the report output considerably.

    Code:
    SELECT [Change Request].CR_ID, DLookUp("Action_Complete","[Change Request]","CR_No = " & [Change Request].[CR_No] & " AND Sub_No<>0") AS IsComp, DLookUp("[Status 1]","[Switching]","CR_No = " & [CR_No]) AS Same, DLookUp("[Date_Closed]","[Change Request]","CR_No= " & [CR_No] & " AND Sub_No=0") AS SDate, IIf([SUB_No]=0,Format([Change Request].[CR_No],"#"),Format([Sub_No]*0.01,"    " & " .00")) AS CR_Numberz, IIf(([IsComp] And [Action_Complete]=False) Or ([Same]<>[Status 1]) Or ([Sdate]<>[Date_Closed] And [Action_Complete]=False),[CR_No] & Trim([CR_Numberz]),[CR_Numberz]) AS CR_Numbers, Vote_Switch.[Status 1]
    FROM [Change Request] INNER JOIN Vote_Switch ON [Change Request].CR_ID = Vote_Switch.CR_ID;

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    the domain functions (DLookup etc) can only return one value and should not really be used in queries.

    why can't you just bring the change request table into your query, linking on CR_No?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combining Dlookup functions
    By Thompyt in forum Programming
    Replies: 4
    Last Post: 01-15-2016, 01:12 PM
  2. Dlookup Function
    By balajigade in forum Access
    Replies: 2
    Last Post: 09-10-2015, 01:55 AM
  3. DLookup Function
    By Alex Motilal in forum Programming
    Replies: 8
    Last Post: 08-14-2014, 01:15 PM
  4. Replies: 3
    Last Post: 05-14-2014, 06:07 AM
  5. DLOOKUP function
    By tariq1 in forum Programming
    Replies: 5
    Last Post: 07-17-2012, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums