+ Reply to Thread
Results 1 to 8 of 8

Userform Add, Edit, Delete

  1. #1
    Registered User
    Join Date
    06-05-2010
    Location
    Manchester, Connecticut
    MS-Off Ver
    Excel 2003
    Posts
    5

    Userform Add, Edit, Delete

    Hi, first time poster hear. I've read many of the posts and there are so many different ways to accomplish what I'm trying to do but being a novice at VBA I'm not sure if this is the best method. It also doesn't seem to be working 100% but I don't understand why.

    In any event, I have a userform that has the displays rows from Sheet1. These rows can be selected from a listbox which then shows the "details" of what they've selected (otherwise the fields are blank and they can add a new record). When they select an existing record my userform shows the existing data - the issue comes in when they try to save/update that data. Below is the code I'm using:

    Please Login or Register  to view this content.
    The first record "txtSiteName" updates but none of the others do. What I would like is for it to search for that record, make all of the updates (in a single row). If it isn't found I would like for it to add a new record. Each row has a unique ID (that is in column A) that I need created when it saves (haven't worked on the Add New button yet so I'm not there yet )

    Again, thanks for any assistance.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,008

    Re: Userform Add, Edit, Delete

    I can't see anything wrong with your code - do you have any event code in the worksheet you are changing?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    06-05-2010
    Location
    Manchester, Connecticut
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Userform Add, Edit, Delete

    Quote Originally Posted by romperstomper View Post
    I can't see anything wrong with your code - do you have any event code in the worksheet you are changing?
    The worksheet has no functionality, it's just where I store the data. I just tested it again and it definately changes the second cell (which is the txtSiteName field) but if I change the address in the userform it changes back to its original content when I hit update.

  4. #4
    Registered User
    Join Date
    06-05-2010
    Location
    Manchester, Connecticut
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Userform Add, Edit, Delete

    Maybe this will be more useful.

    JonSave.xls

    Again, thanks for any assistance.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,008

    Re: Userform Add, Edit, Delete

    Change the Userform_Initialize sub to this:
    Please Login or Register  to view this content.
    If you use the RowSource property (as you were) then when you write the data back to column B, the list updates, which is the same as clicking on the list box, and all your fields get repopulated.

  6. #6
    Registered User
    Join Date
    06-05-2010
    Location
    Manchester, Connecticut
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Userform Add, Edit, Delete

    That worked, thank you! I wasn't even looking there. WOW. Thanks again.
    Last edited by Cutter; 08-28-2012 at 08:57 PM. Reason: Removed whole post quote

  7. #7
    Registered User
    Join Date
    04-26-2011
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Userform Add, Edit, Delete

    I don't know if it's ok to do this here, but I just wanted to say thanks to jonj. I came here with a whole bunch of userform questions and your post answered them all. Thanks.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Userform Add, Edit, Delete

    I don't know if it's ok to do this here
    Yes, it is OK to make a comment, you just can't ask question(s) in someone else's thread.

+ 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