Results 1 to 4 of 4
  1. #1
    mcdownes is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2015
    Location
    Houston, TX
    Posts
    2

    Find End Date based on Start Date of next record using DLookup

    My objective is to populate an end date, based on the start date of the next record for an employee. If no next record, show 12/31 of same year as start date. My question is in two parts. 1) should I use a dlookup, and 2) why is my most basic dlookup giving me an error? Am I using wrong syntax? I thought I would start simple, then play around to see if I can make this work. But even my simple attempt is not working. If there is a better way, I would love to know. Thx for any help!



    Table: "ProRationDates", contains [EEID],[FullName],[StartDate]

    Query: "ProRationDates Sorted" based on ProRationDates table, contains same fields except 1) I've renamed them [prsEEID],[prsStartDate], and 2) the query is sorted by EEID then StartDate (so I can hopefully do some sort of FindNext function to retrieve the next StartDate for the employee. My logic is that I believe I can identify the current EndDate by using next StartDate -1.

    Query2: "Query2" based on ProRationDates table, with an added field called EndDate: DLookUp("[prsStartDate]","ProRationDates Sorted","[prsEEID]=" & [EEID]). But this returns an "ERROR".

    Click image for larger version. 

Name:	ProRation Dates.jpg 
Views:	9 
Size:	113.8 KB 
ID:	21816

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,959
    Domain aggregate functions can be slow performers in queries. Review http://allenbrowne.com/subquery-01.html#AnotherRecord
    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
    mcdownes is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2015
    Location
    Houston, TX
    Posts
    2
    This query will be used only to occasionally refresh a table. So, I'm not concerned about slowing performance. Do you have any suggestion for solving my problem?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,959
    I suggest a nested query as demonstrated in the referenced link.

    Advise no spaces or special characters/punctuation (underscore is exception) in naming convention. If used, enclose name in []. "ProRationDates Sorted" has a space.
    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.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-20-2018, 11:57 PM
  2. Replies: 9
    Last Post: 06-23-2015, 03:13 PM
  3. Replies: 3
    Last Post: 09-24-2013, 07:33 AM
  4. Replies: 2
    Last Post: 07-09-2013, 06:31 PM
  5. Replies: 15
    Last Post: 04-06-2012, 10:57 AM

Tags for this Thread

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