Results 1 to 9 of 9
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Date before today


    I got my query to calculate a date. Now, I need it to only display [ExpDate] is that is equal to or before the current date. I've tried >=Date(), but get an error. Any ideas?

    Click image for larger version. 

Name:	query1.jpg 
Views:	21 
Size:	18.7 KB 
ID:	30932

    Click image for larger version. 

Name:	query2.jpg 
Views:	21 
Size:	48.6 KB 
ID:	30933

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    LESS than:

    <=Date()

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I tried that. I get "Invalid use of null" error.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    filter out the nulls.

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    There are no nulls. When I run the query with the criteria blank, I get all fields filled. That was the first picture I posted. I can't figure out where any nulls are.

  6. #6
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    this cannot be possible, if there are no nulls in the field, then you cannot get 'Invalid use of Nulls' error.
    You are SURE ,that EVERY field has a date in it?
    are there nulls in other fields?

    if this is true, try compact/repair the db. It could be a false error.

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I have this query based on a query. The first query filtered out all nulls. Using "=Date()" works. Using ">=Date()" works. For some reason "<=Date()" gives me that error.

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Post the SQL for the first query.

    Post the SQL for the query that works (>=) and for the one that doesn't (<=).

    The reason that >= works is that any date after today will be a real date and not contain a null. However, null is before today (in the sort sequence) and that is why you get the error. Run the first query without any criteria and sort ascending by the date field, that will show nulls at the top.

  9. #9
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Thank you. That got me thinking about my calculations. I used CDATE to find a date. I took it out and just used the date. That eliminated the null. It works perfectly now.

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

Similar Threads

  1. Replies: 1
    Last Post: 11-26-2013, 09:25 AM
  2. Replies: 3
    Last Post: 02-04-2013, 05:24 PM
  3. Replies: 7
    Last Post: 01-28-2013, 05:21 PM
  4. Replies: 5
    Last Post: 10-12-2012, 11:00 AM
  5. Replies: 12
    Last Post: 04-26-2012, 04:01 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