+ Reply to Thread
Results 1 to 18 of 18

Add a remove button to form

  1. #1
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85

    Add a remove button to form

    I have a userform that adds and deletes employees. The add button works but im not sure how to get the delete button to work. I have a defined name of "Employee" that is row "A". What I would like to happen is that when a employee is selected from a userform list and the delete button is pressed the employee is deleted and the form is updated. Any help is most appreciated. Thank you
    Attached Files Attached Files
    Last edited by Khaos176; 12-19-2008 at 12:18 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this
    Please Login or Register  to view this content.
    The example named range has a #REf error, so I changed the code for initialize
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    Thank you royUk for the quick reply. I have added the code for commandbutton1 and replaced the code for UserForm_Initialize. When I run the program it gives me a Run-time error '424': Object Required.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Works fine for me
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    Hmmm....Your right but the add employee now gives a Run time error '1004'

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I've checked all the coded and made a few alterations
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    Thanks a million!!!
    It works great. Im going back to see what I was doing wrong. Thank you

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  9. #9
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    Found a problem. At first glance it seems to work fine but I noticed when adding employees my list is not getting bigger. Its replacing other names. Any ideas?

  10. #10
    Registered User
    Join Date
    05-02-2007
    Location
    US
    MS-Off Ver
    2000 @work, 2003 @home
    Posts
    23
    Hey, I played with it some, since it is similar to what I had/have been trying to achieve in the past. Still doing it.

    I modified the codes a little, and should be great. I noticed if you accidently hit the delete button it would erase the top row.
    Hope this helps you out
    Attached Files Attached Files
    Last edited by dcraker; 12-18-2008 at 04:42 PM. Reason: size of file bloated
    Thanks,
    David
    yes, there is only one c

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This amended code will add the name correctly

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    So this is now working but I need to actually make a bigger form. I need to add a Job list which is the same as the Employee list. When I use the same concept I run into Run time error 1004.
    Attached Files Attached Files

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by Khaos176 View Post
    So this is now working but I need to actually make a bigger form. I need to add a Job list which is the same as the Employee list. When I use the same concept I run into Run time error 1004.
    It hasn't got the code in that I gave you, are you not using that?

  14. #14
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    I have been playing with all the ideas and got the last posts code to work for me. I did go back and tried playing more with the code you suggested and it still will not work. Thanks again for all your help. I didnt think this section of my program was going to be so difficult.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    Ok I now see the problem. When the data lists are on a different sheet from the main button it is giving me the error. Ill keep trying.

  16. #16
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The code works fine for me, I have amended the code so that it works for each task
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    10-10-2008
    Location
    Illinois
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    85
    I think thats it!!! Thank you again and again!!!

  18. #18
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It should work from any sheet without selecting it.

    I've also set it up to auto generate the next number so that you don't get duplicates, see the initialize code for the jobs textbox. If you delete a number it will still not re-use that number which should avoid confusion. If you use that I would set the textbox Enabled property to false

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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