+ Reply to Thread
Results 1 to 14 of 14

VBA Userform - Search, Edit & Update functionality

  1. #1
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    VBA Userform - Search, Edit & Update functionality

    Dear Excel Forum users,

    I am a VBA newbie and have created the attached database from scratch including a very basic Userform (linked to 'New Entry' in worksheet ÇC) which allows me to add a new guest to my database (refer to CC sheet only).

    Whilst I have looked at the Excel Data Form as an option, it is clunky and I'd rather experiment with VBA to create something more slick and personalised.

    I want to add into the existing Userform (in 'ÇC' worksheet) a 'Search' and 'Édit/Update' option , presumably using command buttons within the Userform itself. I have looked quite extensively on the internet but am struggling to come up with a clear code. When searching i'd ideally like all the criteria in the userform to populate based on a name search with a 'Find Next' function. When executing the Edit/Update option i'd like it to replace the row of existing data rather than populating a new row.

    Apologies in advance if this a simple solution (and for my poor coding no doubt), I do not expect anyone here to code the whole thing for me, rather a few handy pointers would be much appreciated.

    Many thanks,

    Jake @ChiawaCamp
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform - Search, Edit & Update functionality

    Hi Jake,
    So what you're looking for is the possibility to Edit as well as Add records?
    You can use the same userform for that, the 'chunky part' as you call it is that you do not have the option of selecting a record and if it exists just update it.

    Developing a nice and nifty form requires time and time is .... right , you got it.

    I can help with the option to select an existing record to modify it so that you can do this through a form without having to type it into the worksheet.

    You coding (as far as it's yours) is not too bad, I personally always avoid hard-coding things like the Nationality, just have a table which you can modify manually and refer to when the form is loaded.

    But ok, just let me know if you like the idea that I modify the code a little so will also be able to modify and or delete a record.

    Remember once you start coding you have to take into account ALL the options like determining which fields must ALWAYS be completed before allowing to save a new record; the same would also apply to modifying and deletion might altogether be another story

    So you see, a simple question can lead to an entire new vision
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    Re: VBA Userform - Search, Edit & Update functionality

    Dear Keebellah,

    Many thanks for your prompt reply, much appreciated.

    In essence, you've got it. I want to create a database that allows me to add/find/edit/update entries. My initial idea was that the 'search' worksheet would be a cross database search function that negates the need to search via a userform and will be used for general reference (i.e non editable). The userform (I have a separate one for the 'CC' and 'OM' worksheets) will be for adding/editing data. However, I am now thinking that it might be best to do it all through the userform. Perhaps the code would get too complicated for a beginner!

    Any help/modifications/suggestions would be much appreciated. And yes, these projects are very organic with new ideas coming through all the time (I must have spent at least 60 daylight hours so far on this!!). I realise more and more that code needs to be 'clean & clear' so it can be easily referenced/modified at a later date!

    A huge thanks in advance,

    Jake

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform - Search, Edit & Update functionality

    Hi Jake,

    This is just a quick and dirty but it's a beginning, maybe it gives you some ideas and will help you on.
    Attached Files Attached Files

  5. #5
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    512

    Re: VBA Userform - Search, Edit & Update functionality

    hi I've amended your userform, added Search, Amend and Delete

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

  6. #6
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    512

    Re: VBA Userform - Search, Edit & Update functionality

    Hi it might be an idea to add an additional column and search with a Booking Reference Number this saves all the problems with customers having the same name

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform - Search, Edit & Update functionality

    Like I said, once you start ...

  8. #8
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    Re: VBA Userform - Search, Edit & Update functionality

    Dear Keebellah & Toonies,

    Many thanks to you both for your excellent feedback and amendments. Extremely useful and pretty much exactly what I was looking to achieve. I have a few other ideas I want to try myself but will definitely contact you both for any further advice.

    Very best regards,

    Jake

  9. #9
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    Re: VBA Userform - Search, Edit & Update functionality

    Dear Keebellah & Toonies,

    Many thanks to you both for your excellent feedback and amendments. Extremely useful and pretty much exactly what I was looking to achieve. I have a few other ideas I want to try myself but will definitely contact you both for any further advice.

    Very best regards,

    Jake

  10. #10
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    Re: VBA Userform - Search, Edit & Update functionality

    Dear Keebellah & Toonies,

    Many thanks to you both for your excellent feedback and amendments. Extremely useful and pretty much exactly what I was looking to achieve. I have a few other ideas I want to try myself but will definitely contact you both for any further advice.

    Very best regards,

    Jake

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA Userform - Search, Edit & Update functionality

    You're welcome. Don't forget to mark the post solved.

  12. #12
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    Re: VBA Userform - Search, Edit & Update functionality

    Sorry guys, multiple replies due to internet outages here in Zambia.

    Regarding the attached from Toonies, the userform will now not let me add a new entry. Is there a quick fix to this?

    Best regards,

    Jake
    Attached Files Attached Files

  13. #13
    Forum Contributor Toonies's Avatar
    Join Date
    07-30-2009
    Location
    Newcastle, UK
    MS-Off Ver
    Excel 2016
    Posts
    512

    Re: VBA Userform - Search, Edit & Update functionality

    ok I've amended this part of the Add Button code and cleared all rows.

    Also the sheet is then password protected by the userform - password = "password"
    this is to stop data from being deleted accidentally.


    from this

    Please Login or Register  to view this content.


    To this

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

  14. #14
    Registered User
    Join Date
    03-05-2016
    Location
    zambia
    MS-Off Ver
    2013
    Posts
    12

    Re: VBA Userform - Search, Edit & Update functionality

    Dear Toonies,

    Many thanks, all fixed. Great!

    Kindest regards,

    Jake

+ 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 to update data's by using VBA userform also edit by Sl. No
    By Nisar.mohammed in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2015, 10:38 AM
  2. [SOLVED] Need userform to search and edit records
    By Damian37 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-30-2014, 03:16 PM
  3. [SOLVED] VBA Userform Edit/Update record help
    By sa.1985 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2013, 10:29 AM
  4. update value and edit items already update on sheet by userform
    By tjxc32m in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-08-2013, 10:13 AM
  5. [SOLVED] Search and edit data in a Userform
    By flashdisk in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-11-2013, 08:27 AM
  6. edit data in userform and update spreadsheet
    By nunans in forum Excel General
    Replies: 2
    Last Post: 03-08-2012, 04:44 AM
  7. Edit/Update list from userform (auto alphabetized)
    By Jogier505 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-07-2009, 06:28 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