Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    referencing results in the same query,


    I have a query named NoticeQ_1day that displays 3 dates.

    old_date, New_Date, When

    I want the criteria for old date to be greater than when.

    If I use >[NoticeQ_1day].[When] It comes up with an input box asking for this value.
    if I use >[When] it displays all results even the ones before when.

    What am I doing wrong?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I would expect the second to work. In SQL view:

    WHERE old_date > When

    That assumes they are fields in a table being returned by the query, not calculated in the query. It also assumes they are date/time values, not text.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Sorry for the late reply, I've been busy on other things Paul. They are being calculated on the query. How would you suggest I proceed?

    I can re-write the question if you need more info.

    Andy.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Try running the query with no criteria, just the three values.

    Are there any rows where [Old_Date] actually is > [when] ?

    This might be stating the obvious, but bear in mind that When comparing dates, [Old_Date] > [when] means [Old_Date] is more recent than [when]. Is that what you want?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If they are calculated in the query you can't use the alias. Try repeating the calculation. In SQL view:

    WHERE CalculationForOldDate > CalculationForWhen
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Hello John. That is correct.

    Its a scheduled start date so its always AFTER when.

    When = date of change.

    Paul - Thanks for that suggestion. I will look at this tomorrow.

    So if we change a scheduled start date it always a date in the near future.

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

Similar Threads

  1. Referencing search results
    By Homegrownandy in forum Access
    Replies: 5
    Last Post: 07-21-2015, 10:10 AM
  2. Replies: 2
    Last Post: 08-09-2013, 09:21 AM
  3. Replies: 6
    Last Post: 05-14-2012, 07:24 AM
  4. Referencing a query field
    By rcrobman in forum Queries
    Replies: 5
    Last Post: 04-29-2011, 04:06 PM
  5. referencing combobox in query
    By Sparty in forum Forms
    Replies: 2
    Last Post: 09-27-2010, 11:32 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