+ Reply to Thread
Results 1 to 9 of 9

Problematic ‘Edit’ code in Multiple Page Userform

  1. #1
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Problematic ‘Edit’ code in Multiple Page Userform

    Dear All,

    I should be very grateful if you would, please, help me tweak the ‘Edit’ code so that it will work correctly my Multiple Page Userform.

    With some help, I have been able to put together a Multiple Page Userform (two userforms combined together) – one for Students and the other for Employees.

    I am having problems getting the ‘Edit’ code to work for the ‘Employees’ userform. It works OK for the ‘Students’ userform.

    1. When for e.g. a letter ‘e’ is typed into the ‘Filter Combo box’, the ‘Lookup Criteria’ box is automatically populated with the list of records containing the letter ‘e’.

    2. And if e.g. the record of a student is clicked in the Lookup Criteria box, the ‘Student’ userform is populated with the full records of the student from the database. So also if the record of an employee is clicked, the ‘employee’ userform is equally populated.

    3. However, when a user populates the student userform with a student’s record, and then amends the student’s record and clicks the ‘Edit’ button, the said student’s records are correctly updated.
    4. The ‘Edit’ button is supposed to work for both userforms.

    5. However, when a user populates the employee userform with the record of an employee and then amends the employee’s record and clicks the ‘Edit’ button, the ‘Edit’ code seems not to work correctly for updating such employee’s record.

    Please, I need help to tweak the ‘Edit’ code for me so that it will work for both the ‘student userform’ and also the ‘employee userform’.

    I have attached to this thread a sample file of the said Multiple Page Userform (with the codes). I am also appending below, the problematic ‘Edit’ code, and should be grateful for your kind help.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    How is the employee record not being updated correctly?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    Thanks Norie for your kind response. Yes, employee records are not being updated when you click the ‘EDIT’ button. For eg.

    1. When you activate the attached sample file (the Userform), you will observe that there are two sides to it – the Student Userform and the Employee Userform.

    2. At the top of all these are the ‘Filter combo box’ and the ‘Lookup Criteria Box’. These are common to both Userforms as you will observe.

    3. If you click for eg. on the Student Userform, and type say ‘e’ into the Filter Combo box, the Lookup Criteria Box gets populated with the records (names, etc.) of everybody – students and employees, respectively – that has the letter ‘e’ in their names.

    4. If you then click on the record of any student (and given that you are on the Student Userform), the records (full details) of the student you have clicked will populate the Student Userform.

    5. While the Student Userform is populated, a user can change/alter any bit of that student’s details from the userform.

    6. If you do so and click the ‘EDIT’ button (which serves as the ‘Update’ button, the said student’s record will be updated with the change(s) made. These changes will automatically show in the Lookup Criteria Box and also be reflected in the Database. This Update process (using the EDIT’ button) works OK for the Students userform/records.

    7. If, on the other hand a user decides to do the same thing (3 to 6 above) on the Employee Userform, the EDIT button does not update any changes made to any employee’s records, and the Employee’s record is also not updated in the Database.

    I believe that the EDIT code needs tweaking to be able to work correctly for the Employee Userform as it does for the Student Userform, as explained above.

    I need help with the EDIT code to achieve this, please.

    Thank you

    Buddy8.

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    The control names in the Student tab start with 1, however the Employee controls start at 15, so you'll have to account for that when using this loop.

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  5. #5
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    Hi Tinbendr,

    Thanks very much for your kind response and for your observation.

    As I indicated in my first Post, I had so much help with respect to the coding. My VBA knowledge and skills are very basic and I am always willing to learn.

    I don't know how to tweak the Employee controls to take account of what you pointed out. I should be very grateful if you would, please, help me out with that.

    Thanks for your help.

    Buddy8

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    This seems to work.

    I've made a few changes all over, so I'll just upload the file.

  7. #7
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    Hi Tinbendr,

    Thanks for amending the ‘Edit’ code. I have tested the amended code, but unfortunately, it is still not working correctly.

    Below is an explanation of what I observed upon testing the code:

    1. When you choose an Employee from the Lookup Criteria box which is at the top, the Employee userform is populated with the employee’s record. When you make any change(s) to that record and click the ‘Edit’ button, the record disappears completely from the Lookup Criteria Box. It should not work that way. The record should still be showing in the Lookup Criteria box and immediately takes on the updated version of the record.

    2. Also if you check the same record in the Database sheet, the code moves some of column entries for that employees around – placing them in the wrong columns. E.g, it moves the employee’s entry that was originally in column ‘G’ to column ‘O’. Column ‘O’ should not have any entry for Employees.

    3. The code also takes a copy of the entry in column ‘Q’ and uses it to overwrite the original entry that was in column ‘G’.

    4. On the other hand, if you choose a Student record from the Lookup Criteria box and populate the Student Userform with the said student’s record and then make any changes to that student’s record – if the ‘Edit’ button is clicked, you will see that record on the Lookup Criteria Box automatically updated. On checking the Database sheet, the same record will be correctly updated.

    5. The problem is only with the updating of Employee records.

    I am hoping that whatever part of the Edit code that is causing the problem would be ascertained and corrected.

    Thanks for your continued support.

    Buddy
    Last edited by Buddy8; 07-13-2016 at 11:35 PM.

  8. #8
    Forum Contributor
    Join Date
    05-14-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    120

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    I'll appreciate help with this, please.

    Thanks all.

    Buddy

  9. #9
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Problematic ‘Edit’ code in Multiple Page Userform

    I went back to your original file.

    Change this.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I code an Edit button for a userform?
    By gmr4evr1 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-23-2015, 09:51 AM
  2. Can't get userform code to edit/append/delete comments
    By misty15 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2015, 05:32 PM
  3. Edit VBA Userform code to run if only 1 entry that matches criteria
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-24-2013, 05:25 AM
  4. select multiple column listbox to edit userform
    By tbar05 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2012, 12:13 AM
  5. VBA Code to Search/Edit Data Populated by Userform
    By pjohnson9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2011, 04:25 PM
  6. UserForm to return and edit multiple rows
    By liamsnodden in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2010, 04:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1