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

    Combining Dlookup functions

    I have the following in a Query (Switching)



    CR_Number: Format(([CR_No]+([Sub_No]*0.01)),"Fixed")

    CR_Numberz: IIf([SUB_No]=0,Format([Change Request].[CR_No],"#"),Format([Sub_No]*0.01," " & " .00"))

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

    CR_Numbers: IIf([IsComp] And [sub_no]<>0 And [Action_Complete]=False,[CR_No] & Trim([CR_Numberz]),[CR_Numberz])

    I was also looking into adding the following. (It slows the process extremely)

    Same: DLookUp("[Status 1]","[Chng_ReqQry]","CR_No = " & [CR_No] & " AND Sub_No<>0") , it is a roundabout way since Status 1 is from the same Query Switching and then inserting outcome into CR_Numbers as:

    CR_Numbers: IIf([IsComp] And [Action_Complete]=False Or Same <> Status 1 And Action_Complete=True ,[CR_No] & Trim([CR_Numberz]),[CR_Numberz])

    This will work until I restart the database, then it locks up. I have to remove the Or Same <> [Status 1] from CR_Numbers.

    Is there an easier way to combine?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You are mixing OR and AND logical operators. Parentheses are critical.

    Literal text needs delimiters.

    Do you mean:

    CR_Numbers: IIf(([IsComp] And [Action_Complete]=False) Or (Same <> "Status 1" And Action_Complete=True), [CR_No] & Trim([CR_Numberz]), [CR_Numberz])
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    Thanks June
    It does work on that Query - Switching. But is real slow and if I run a report using this, I get an unknown error multiple times. Enough I have to use the Task manager to kill Access.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Yes, domain aggregates can perform slowly in queries and textboxes.

    Perhaps need to look at revising data structure so you can have a join to retrieve the related info.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    June,
    Fixed the slowness. I shortened the Same Code to:

    Same: DLookUp("[Status 1]","[Chng_ReqQry]","CR_No = " & [CR_No])
    CR_Numbers: IIf(([IsComp] And [Sub_no]<>0 And [Action_Complete]=False) Or (Same<>[Status 1]),[CR_No] & Trim([CR_Numberz]),[CR_Numberz])

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

Similar Threads

  1. Functions
    By gelabelle in forum Modules
    Replies: 2
    Last Post: 11-11-2015, 11:53 PM
  2. Help with functions
    By cc.caroline15 in forum Programming
    Replies: 5
    Last Post: 02-04-2015, 08:26 PM
  3. Replies: 14
    Last Post: 07-22-2013, 12:39 PM
  4. F functions
    By dref in forum Access
    Replies: 1
    Last Post: 08-23-2012, 06:13 AM
  5. Functions
    By Alex Motilal in forum Programming
    Replies: 2
    Last Post: 09-27-2010, 08:06 AM

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