Your welcome. I'm glad I was able to help.
I may have to place it in a public Dropbox or Google cloud drive, for it is 5MB.
If you zip the file, ExcelForum may allow a larger file. It's a lot easier to work on a sample file, but I imagine a lot of the 5MB is probably redundant, and can be deleted from the sample file, because small files are a lot easier to work with.
Now that the Userform can look up existing data (thanks to you), I want to add an "Update" cmdbutton to the form, that, when clicked will over-write existing data in the database when a user makes a change to any of the textboxes that are showing with the data we have found using the cmdFind sub.
Again, my suspicion is that I am looking the answer in the face, and that by copying the code from cmdOK3 sub into the cmdUpdate sub (not written yet), and modify it with a Find and Replace, or if Change() function, it should do the job?
This one is best done with a little trickery.
In order to do this, you need to know the row number in the SpreadSheet that you will overwrite. You already know the row number when you put the data in the UserForm. All you need is a place to put it. There is a little known attribute of each UserForm control named the 'Tag' attribute. It is there for the programmer to use for any reason the programmer wants. It is a good spot to store the row number in the SpreadSheet. For example to store the value in the Label Tag Attribute:
Now when it's time to update, you can extract the row number. You also probably don't want to update a row where the value didn't change. First you need to save the current value in the spreadsheet. This can be done by using the Tag attribute for the TextBox (also included in the code above). cmdOK3_Click() code will have to be rewritten for this, and the variant array will be discarded. I'll show you how to do this in my next post.
Lewis
Bookmarks