Results 1 to 11 of 11
  1. #1
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41

    Dlookup or Dlast

    I have a form that a user scans in their ID and I'm wanting the Afterupdate to search for the last record entered by that person and populate the rest of the form fields if there is one, if not, then just let them continue to fill in the fields for their first record. What is the best way to do this? TIA

  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,518
    Since you mention multiple fields, I'd use a recordset, much more efficient than multiple domain aggregate fumctions. DLast() wouldn't do what you think, and DLookup() would require you to first identify the last record. The recordset can use SQL with a criteria on the person and the TOP predicate to get their last record.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41
    Can you expand on that? I'm a novice at this.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Are you adding a new record each time the user scans their ID (in which case you are copying their previous record to a new one)? Or are you merely displaying information?

  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,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41
    The info is just to populate with the latest data and then create a new record with new info from the other fields not populated.

  7. #7
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Make the new record a subform, when the user scans in their id run a query to add a new record to the table based on the old record, then requery the subform with filters to display the record just added.
    If there is no old record then add a new record anyway and the subform will show blank fields for them to fill in.

  8. #8
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41

    ??

    Quote Originally Posted by aytee111 View Post
    Make the new record a subform, when the user scans in their id run a query to add a new record to the table based on the old record, then requery the subform with filters to display the record just added.
    If there is no old record then add a new record anyway and the subform will show blank fields for them to fill in.
    Not sure, how to go about coding something like that! Just a novice here. Could you show me or point me to a sample that coding?

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    fspata is offline Advanced Beginner
    Windows 8 Access 2007
    Join Date
    Oct 2015
    Posts
    41
    Paul, I am definitely looking at your suggestion also. Just looking for the quickest fix for this, under a real time constraint. Sorry, wasn't trying to ignore your suggestion or you.

  11. #11
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a query that finds the record you are looking for (if one exists) - use "TOP" as mentioned above. Get this query working and then show us the SQL.

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

Similar Threads

  1. DLast not getting last record
    By Ron99 in forum Access
    Replies: 13
    Last Post: 06-21-2017, 05:25 AM
  2. Dlast with multiple criteria
    By sdel_nevo in forum Programming
    Replies: 5
    Last Post: 02-29-2016, 07:34 AM
  3. DLast not working
    By abusaif in forum Access
    Replies: 4
    Last Post: 11-18-2014, 06:22 AM
  4. DLast
    By alyon in forum Access
    Replies: 4
    Last Post: 12-21-2012, 02:01 PM
  5. vba Dlast for each page!
    By Ivanho in forum Reports
    Replies: 0
    Last Post: 11-23-2011, 04:27 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