Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    dmax value


    Hi All

    I am struggling with a dmax, i have a continuous form called "stock levels" that has this code in an unbound textbox called "stock level on hand"

    =Nz(DSum("[stock holding]","stock take","productID=" & [ProductID]),0)+Nz(DSum("qty","purchaseOrders Details","productID=" & [ProductID]),0)-Nz(DSum("qty","Orders Details","productID=" & [ProductID]),0)

    basically this take the value from the stock holding adds it to the sum of the qty on the purchase orders and then subtracts the amount on invoices

    this works really well, but the problem i have is that i need to change this part =Nz(DSum("[stock holding]","stock take","productID=" & [ProductID]),0)

    i think i need a Dmax, but i can't workout what i need to do to get the "[Stock Holding]" value based from the last "[Stock take Date]" I can't seem to work out how i can set the criteria as both the productid and the "[stock take date]"

    hope this makes sense

    many thanks

    steve

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    That will be tricky, like:

    =Nz(DSum("[stock holding]","[stock take]","productID=" & [ProductID] & " AND [stock take date]=#" & DMax("[stock take date]","[stock take]","ProductID=" & [ProductID]) & "#"),0)

    I am surprised your expression is working because table names with spaces are not enclosed by [].
    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
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi June

    Thats brill, works like a charm many thanks

    Steve

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

Similar Threads

  1. DMax() with date
    By rkalapura in forum Forms
    Replies: 1
    Last Post: 11-17-2012, 11:17 PM
  2. DMAX in VBA
    By Meanfish in forum Access
    Replies: 1
    Last Post: 11-03-2012, 11:06 AM
  3. Replies: 6
    Last Post: 07-24-2012, 03:02 PM
  4. How to use DMAX
    By tomneedshelp in forum Access
    Replies: 2
    Last Post: 03-01-2012, 07:22 AM
  5. Using Nz and Dmax
    By timmy in forum Programming
    Replies: 5
    Last Post: 07-04-2011, 06:42 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