Results 1 to 6 of 6
  1. #1
    jnrussell is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    17

    Trying to compare dates to parameter date not working


    I have a table of aquarium tank contents. When an animal is put in the tank the date and genus species is entered. When animals are removed the date and genus species is entered as another record. I'm trying to create a query that shows what animals are in the tank on a specific date. I've created a parameter for the query that prompts for the date. However, I've tried all sorts of criteria for the date field using that parameter and either end up with all the records in the table or only the ones that match the parameter date. What syntax should I use for the criteria to make this work?

  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,652
    I might have designed it differently, but I assume there's something that differentiates a "going in" record from a "coming out" record? Presuming so, you basically have an inventory situation, so you'd add up the transactions (going in's minus coming out's) as of the desired date. If you're still stuck and can provide a sample db, it may be easier to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jnrussell is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    17
    The only thing that designates "going in" and coming out" is a positive or negative number of animals. It is mostly used to track transfers between tanks, but we also want to be able to see what is in a tank on a given date. Since I'm still in the designing process of the database, I'd be interested to hear how you would have designed this table differently.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I said might because it depends on the data. If you were referring to specific animals, I might have used a single record with fields for both in and out dates. Fish number xyz when in on 1/17/2014 and came out on 1/31/2014 type of thing. If you're putting in 50 of species xyz on one date and might take out 10 on another date, 10 more on some other date, I'd leave it like you have it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jnrussell is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    17
    Yes, we might be taking out different numbers than we put in, like if one dies. I did get the report I need. I created two queries for the report. The first finds all records less than or equal to the date I'm interested in. The second query is based on the first and sums the number of animals. My mistake was trying to use two date when I only needed to have it look at dates less than or equal to the one I want. And I also needed the second query to add the number of animals in the records that the first query found.

    Thanks for your help. It got me to thinking in a different direction, which was exactly what I needed.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I would have thought it could be done with one query, but glad you have a working solution.
    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. Same dates different fields compare
    By Ruegen in forum Programming
    Replies: 3
    Last Post: 11-18-2013, 10:57 PM
  2. How to compare dates in two form fields
    By wardw in forum Forms
    Replies: 4
    Last Post: 09-16-2013, 10:05 AM
  3. Replies: 6
    Last Post: 02-28-2013, 05:38 PM
  4. Compare dates in vba
    By rjbautista20 in forum Programming
    Replies: 1
    Last Post: 08-17-2012, 09:44 AM
  5. Replies: 1
    Last Post: 02-17-2012, 04:43 PM

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