Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8

    Dlookup Function with Multiple Criteria in Query

    Expr1: IIf(IsNull([Cost]);DLookUp("[Cost]";"Items Cost Query";" [Control_No] = & [Control_No] " And " [Transaction_Type] =' Addition ' ");[Cost])

    I Created this syntax to fill value for item when [Transaction_Type] = Removal with value to the same item when [Transaction_Type] = Addition



    But return the value for the first item in the query

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    no semis, use commas.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Instead of dlookup, you could just use a query and join it to the [Items Cost Query]. this does the lookup.
    then you need 2 queries
    1.
    (IsNull([Cost]) to join to LOOKUP table
    2.NOT
    (IsNull([Cost]) ,no join.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I think non-U.S. versions of Access use semi-colon.

    Missing &. Missing ". Unnecessary " and spaces in the criteria string (spaces in ' Addition ' will cause match to fail). Table/query name has spaces, use [].

    Expr1: IIf(IsNull([Cost]); DLookUp("[Cost]"; "[Items Cost Query]"; "[Control_No] =" & [Control_No] & " And [Transaction_Type] ='Addition'"); [Cost])
    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
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8
    Thanks for your Care
    I don't understand how can i make 2 Query

  6. #6
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8
    Thanks for your Care
    But It's return null value

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The syntax I suggest is correct. It returns Null because no data matches the criteria. I don't know your data structure so don't know why it fails. Is Control_No a number type field?
    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.

  8. #8
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8
    Item_Cost: IIf([Cost] Is Null;(DLookUp("[Cost]";"Items Cost Query";"[ID_Inv_Tr]=" & [ID_Inv_Tr]-1));[Cost])

    this is another syntax but it's fill one filed by the correct value but the second filed is null

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't know your db so can't say why that happens.
    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.

  10. #10
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8
    ID_Inv_Tr
    Control_No
    Code_No
    Category
    Transaction_Type
    Transaction_Date
    Cost
    Quants
    This's my Query to Calculate Inventory Cost ( Transaction_Type "Add & Remove" ) when adding items with cost but when removing without cost
    the balances of items quantities ( add - remove )

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Those are fields but not a query statement. Last post makes no sense to me.
    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.

  12. #12
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8
    ID_Inv_Tr Control_No Code_No Category Transaction_Type Tran_Date Cost Quants
    1 125 SP00125 Spare Parts Addition 2014/11/25 9.95 18
    2 125 SP00125 Spare Parts Removal 2014/11/27 -3
    3 125 SP00125 Spare Parts Removal 2014/12/01 -2
    4 125 SP00125 Spare Parts Addition 2014/12/05 10.05 10
    5 125 SP00125 Spare Parts Removal 2014/12/08 -3
    6 125 SP00125 Spare Parts Removal 2014/12/11 -4


    I'm sorry if i cant explain
    this's my simple data
    i want fill cost filed by Addition value to calculate balance of quantity and it's cost

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    How would the "cost" of balance be determined?

    Should enter raw data into table and do aggregate calcs (such as quantity balance) when needed in queries or reports. Aggregate calcs should not be saved into table.
    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.

  14. #14
    wadheda is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Posts
    8
    To calculate the cost i want fill the Blank fields as it's Arrange by the item cost which previously then ( Cost * Quants )in new column "Result" then sum the result With Note when transaction type = Remove the result is (-)

    but regardless my question how can i fill the Blank fields as it's Arrange by the item cost which previously?

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If I understand, you want the 'Removal' records to pull value from another record of same table. That requires nested subquery or DLookup() domain aggregate function.

    http://allenbrowne.com/subquery-01.html#AnotherRecord
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with multiple criteria DLookup
    By jtm013 in forum Programming
    Replies: 7
    Last Post: 04-23-2015, 03:16 PM
  2. DLookup with multiple criteria
    By RunTime91 in forum Access
    Replies: 4
    Last Post: 02-08-2015, 08:28 PM
  3. Replies: 4
    Last Post: 06-30-2014, 02:53 PM
  4. Using DLookup with multiple criteria
    By halt4814 in forum Access
    Replies: 2
    Last Post: 04-08-2013, 12:26 PM
  5. Multiple criteria in DLookup
    By crowegreg in forum Forms
    Replies: 7
    Last Post: 06-22-2011, 01:47 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