Results 1 to 2 of 2
  1. #1
    bearsgone is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    4

    Form output data manipulation

    Hello


    I have a form that has a search button. Search button calls on a query.

    SELECT DISTINCTROW Info.InfoEntryID, Info.InfoBarrelNum, Info.InfoPh, Info.InfoSalinity, Info.InfoAcid, Info.InfoDip, Info.InfoText, Info.InfoMRU, Info.InfoBarrelID, Max(Info.InfoDate) AS MaxOfInfoDate
    FROM Info
    GROUP BY Info.InfoEntryID, Info.InfoBarrelNum, Info.InfoPh, Info.InfoSalinity, Info.InfoAcid, Info.InfoDip, Info.InfoText, Info.InfoMRU, Info.InfoBarrelID
    HAVING (((Info.InfoPh)>=[Forms]![frmInfoBatchEntry]![phLow] And (Info.InfoPh)<=[Forms]![frmInfoBatchEntry]![phHigh]) AND ((Info.InfoSalinity)>=[Forms]![frmInfoBatchEntry]![SaltLow] And (Info.InfoSalinity)<=[Forms]![frmInfoBatchEntry]![SaltHigh]) AND ((Info.InfoAcid)>=[Forms]![frmInfoBatchEntry]![AcidLow] And (Info.InfoAcid)<=[Forms]![frmInfoBatchEntry]![AcidHigh]) AND ((Info.InfoDip)>=[Forms]![frmInfoBatchEntry]![DipLow] And (Info.InfoDip)<=[Forms]![frmInfoBatchEntry]![DipHigh]) AND ((Max(Info.InfoDate))>=[Forms]![frmInfoBatchEntry]![DateFrom] And (Max(Info.InfoDate))<=[Forms]![frmInfoBatchEntry]![DateTo]));

    The outcome of the query is below but incorrect:

    Range 1/1/2010 - 2/1/2010

    Date Barrel Acid
    1/1/2010 5 6
    1/2/2010 5 7
    1/1/2010 6 8
    5/1/2010 7 1

    However the correct out put should be 3 records, first record is gone because it is not the latest input for that barrel.

    Date Barrel Acid
    1/2/2010 5 7
    1/1/2010 6 8
    5/1/2010 7 1


    For any given date range (((Info.InfoDate)>=[Forms]![frmInfoBatchEntry]![DateFrom] And (Info.InfoDate)<=[Forms]![frmInfoBatchEntry]![DateTo])
    if there are multiple barrels select the barrel with the latest date. So it is date range with maximum date if there are multiple identical barrels.
    Any ideas or examples would be greatly appreciated.
    Thank you

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Is this what you're looking for?

    http://www.baldyweb.com/LastValue.htm

    You're getting the result you are because you're grouping on Acid. 6 is different than 7 so represents a separate "group".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Form manipulation error
    By witooldas in forum Forms
    Replies: 6
    Last Post: 03-18-2011, 02:40 AM
  2. Form to Output Table
    By dwright in forum Forms
    Replies: 65
    Last Post: 02-09-2011, 08:54 AM
  3. date manipulation
    By lpsd in forum Access
    Replies: 3
    Last Post: 12-23-2010, 12:06 PM
  4. Form Manipulation examples
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:03 AM
  5. Query manipulation using VBA
    By benattal in forum Programming
    Replies: 0
    Last Post: 12-31-2008, 09:12 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