Results 1 to 6 of 6
  1. #1
    Secue is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    33

    Question Need to populate a new record on a subform with same data from the previous record

    Hi:

    I have a table with some header data and a subtable, I have an optio for users to enter new data on the subform for an especific ID on the main table. What I need to know is what is neede to work as I need:


    - When I open the form to add data on the subform, I need to have this subform set to add a new record, but with some fields already populated with the same information for that field on the previous record.

    Not sure If this is clear.

    Thank you.

  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
    53,626
    That will require code to find the 'previous' record and populate fields of the new record.

    What determines the most recent previous record - a date, an ID number.
    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
    Secue is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    33
    June7

    It could be a date or a field I have which is the revisión of the docuemtn (my dtabase is to control some docuemtn versions). ID is not piossible to be use, since this is the link form my child table with the main table.

    I could have a record on my main table with some basic information, the I have a child table linked by the ID where I'm adding infomrtion for each revisión on the document.

    I want to ente to my form to add a new revisión, them I look for ID and form display's part of the main table and the secondary table as a subform, on this subform I have it set as to show a new record to entry data, I need to have populated this subform with the information of the previous record ( for example the infomtion for the Revisión A of the docuemnt), so the user can change any of the data on the other fields (mainly Revisión and dates).

    I see in other thread a lonk to a nother page explainig something similar, bu it dis not work for me, unless I did something wrong. this is the address: http://access.mvps.org/access/forms/frm0012.htm

    Thank you.

  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
    53,626
    No, that is relevent only when manually entering data to a new record and want values carried forward to subsequent records in the same session.

    You want form to open to new record with data filled in from existing record. This is trickier. I am sure this has been discussed in forum but not finding threads so I googled: access vba how to find last record.

    This example http://p2p.wrox.com/access-vba/72604...ed-record.html shows code that opens a recordset in VBA, moves to the last record, pulls data from recordset fields and populates the new record. As always, the real trick is figuring out what event to put this code in.
    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.

  5. #5
    Secue is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jun 2013
    Posts
    33
    I found the answer using function DLAst.
    http://www.techonthenet.com/access/f...main/dlast.php

    Thak you.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Be careful with DLast. It can return unexpected results.
    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: 12
    Last Post: 12-06-2012, 05:36 PM
  2. Replies: 1
    Last Post: 04-25-2012, 11:56 AM
  3. Replies: 1
    Last Post: 07-25-2011, 09:41 AM
  4. Replies: 1
    Last Post: 04-21-2011, 11:27 AM
  5. Populate date from previous record
    By Lianes in forum Access
    Replies: 3
    Last Post: 09-19-2009, 03:42 PM

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