Results 1 to 7 of 7
  1. #1
    tjb1 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2015
    Posts
    4

    Editing table entry from Form

    Hello, I have a Form that is used for creating entries to fill a table. On the same Form there is also a list that shows everything in the table and a double click on the list will populate the Form with that data. The problem is that "Save Record" command button will not update the table because it thinks it is creating a new record.



    The code to populate the form from the list is


    Private Sub EmployeeEntryList_DblClick(Cancel As Integer)
    Me![Number] = EmployeeEntryList.Column(0)
    Me![EmployeeNumber] = EmployeeEntryList.Column(1)
    Me![FirstName] = EmployeeEntryList.Column(2)
    Me![MiddleInitial] = EmployeeEntryList.Column(3)
    Me![LastName] = EmployeeEntryList.Column(4)
    Me![Supervisor] = EmployeeEntryList.Column(5)
    Me![Group] = EmployeeEntryList.Column(6)
    Me![Shift] = EmployeeEntryList.Column(7)

    End Sub


    I'm not sure how I can make it populate the form if an entry is double clicked and then be able to save a modified version of that record over top the original. Thanks

  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,642
    If the form is bound to the table, you'd need to navigate to the record you want to edit first. Is one of those fields a key field that represents the record to edit?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tjb1 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2015
    Posts
    4
    The number field is a key field since it is unique to each employee but it is not auto generated.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    Why are you saving all those data? Are you editing the employee record in Employees table? If you are populating another table with all that employee info - shouldn't. Save only the Number or EmployeeNumber, whichever is defined as the primary key field.

    Use bound form and no VBA to save value is needed.
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You aren't requerying, but you can adapt this to go to the specified record before copying values:

    http://www.baldyweb.com/Requery.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    tjb1 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2015
    Posts
    4
    The form is bound to the table with all that data, there is a list on the form that displays the table. The VBA populates the form with the info from the table with the intention of editing the data which is where I'm stuck... The form also allows the addition of new data.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    Is this form BOUND to the table?

    Use of ! as you have usually indicates reference to a field. If this form is BOUND and textboxes are BOUND to fields, this code is not necessary and is actually probably causing difficulty.

    Here is one method for locating existing record for editing. http://www.allenbrowne.com/ser-62.html
    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: 3
    Last Post: 06-04-2015, 09:48 AM
  2. Form Editing my Table
    By derek7467 in forum Forms
    Replies: 10
    Last Post: 02-05-2014, 07:45 AM
  3. Editing a table with form via VBA
    By WickidWe in forum Forms
    Replies: 7
    Last Post: 12-12-2013, 08:48 PM
  4. Replies: 1
    Last Post: 06-18-2013, 08:33 PM
  5. Editing Records In Table Using Form
    By ffezz in forum Programming
    Replies: 3
    Last Post: 03-14-2012, 01:40 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