Results 1 to 2 of 2
  1. #1
    gkaro is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    18

    Selecting Max values

    Hi all, first post...

    I have a database that has 5 columns

    YEAR, WEEK, RETAILER, SALES(quantity), INVENTORY(quantity).

    What I would like to do is query the DB to show sales for every WEEK and YEAR, but only INVENTORY for the latest YEAR and WEEK. With blanks or zeros for every older period.



    Something like this

    2010, 01, COSTCO, 150, 0(or blank)
    2010, 02, COSTCO, 176, 0(or blank)
    2011, 04, COSTCO, 142, 0(or blank)
    etc
    etc,
    etc,
    but for the latest week
    2012, 05, COSTCO, 112, 657 (assume this is the most recent entry)

    what I do not want to do is change the history and make all prev values on INVENTORY 0

    hope this makes sense.
    thanks
    gkaro.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,603
    Use IIf expression in query to construct a field. Will need year and week as input parameters, like:

    InvQty: IIf([Year]<>2012 And [Week]<>"05", Null, [Inventory])

    That example shows the parameters as fixed but could be references to controls on form or derived from current date:

    InvQty: IIf([Year]<>Forms!formname!Yeartextboxname And [Week]<>Forms!formname!Weektextboxname, Null, [Inventory])

    InvQty: IIf([Year]<>Year(Date()) And [Week]<>Format(Format(Date(), "ww"),"00"), Null, [Inventory])
    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.

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

Similar Threads

  1. Update Query selecting multiple values in one field
    By Zipster1967 in forum Queries
    Replies: 1
    Last Post: 08-15-2011, 12:22 PM
  2. Selecting multiple values to be used in a report.
    By mnsemple83 in forum Reports
    Replies: 1
    Last Post: 08-12-2011, 05:10 PM
  3. Selecting Dates
    By jpalk in forum Queries
    Replies: 3
    Last Post: 05-21-2010, 06:08 AM
  4. Selecting between two dates
    By nicorvp in forum Queries
    Replies: 5
    Last Post: 05-04-2010, 08:17 AM
  5. Selecting foreign key values on data entry
    By hardya in forum Access
    Replies: 4
    Last Post: 02-11-2010, 11:56 AM

Tags for this Thread

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