Results 1 to 4 of 4
  1. #1
    johnsmith1 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    17

    Dmin Function in Calculated Field of An Access Query

    Hi all,
    I am using the SQL code below in an Access 2010 query to distinguish turtle capture events as "New" or "Recapture".



    SELECT [tbl_Watamu Turtle Bycatch Data].[DateTime Caught], [tbl_Watamu Turtle Bycatch Data].[Tag 1], IIf([DateTime Caught]=DMin("[DateTime Caught]","tbl_Watamu Turtle Bycatch Data","[Tag 1]='" & [Tag 1] & "'"),"New","Recapture") AS [ReleaseType]
    FROM [tbl_Watamu Turtle Bycatch Data];

    A record in my main table represents a capture event. The first time a Tag appears, the associated capture event should be designated "New" in "ReleaseType" field. And whenever the same tag reappears/for all subsequent captures it should be designated "Recapture". However, this query returns "Recapture" ONLY for REcapture events in Years after the Year of first capture. This means that if a Tag appears for the first time in a capture event recorded on 01/Jan/2012, that capture event gets "New" in its "ReleaseType" field: Which is correct. Now problem is, if the 2nd/3rd/4th.. captures are in the same year, the query STILL returns "New" in its "ReleaseType" field. It only returns "Recapture" for the recapture events in 2013, 2014 etc. My date field is "DateTimeCaught" and follows the format: "dd,mm,yyyy hhmm", so I assume the query should be able to distinguish the dates to the hour.
    How do I rectify this?
    Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Could you provide data (spreadsheet or Access) so can analyze and test query? Follow instructions at bottom of my post.
    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.

  3. #3
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    75
    You might want to add a column to your query just displaying the DMin function to see what data it is returning. That might help you figure out the problem.

  4. #4
    johnsmith1 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    17
    Hi all, I have managed to sort the problem. Actually, the above query is correct and working fine. But the proofing query I was using just to be sure had a small glitch. All happy now, Thanks all and sorry for not exhausting all options prior to posting this thread: I just didn't see them.

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

Similar Threads

  1. Parameter Query on a calculated field
    By l3111 in forum Queries
    Replies: 5
    Last Post: 10-12-2011, 02:18 PM
  2. Update Query with a Calculated field
    By Lorlai in forum Queries
    Replies: 3
    Last Post: 09-21-2011, 10:57 AM
  3. Help with Dmin function
    By ohthesilhouettes in forum Queries
    Replies: 2
    Last Post: 06-19-2011, 02:53 AM
  4. union query with a calculated field
    By grad2009 in forum Queries
    Replies: 9
    Last Post: 03-31-2010, 04:50 PM
  5. Replies: 4
    Last Post: 03-05-2010, 09:56 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