PDA

View Full Version : Userform to edit records in different sheets



aloy78
07-14-2012, 10:30 PM
Hi all,

I'm trying to create a userform to edit my records that are different sheets. I have no problem adding but to edit it is a different story altogether :)

What I need is basically I will have a drop down list (just like the one in my add record button), which enables me to select the sheet I want to edit. Then i type in the Record No and click "Search Record No", and it will retrieve the existing data. All I have to do next is amend my data and click "Save Record" to amend and save my changes.

I have attached my file for your review.

Rob342
07-16-2012, 04:52 AM
aloy78

Theres no initialization on the forms to load the data, sheets do not correspond with code.
Can tell us what you are trying to accomplish from the sheets into the form, then we'll take it from there.

CodeNinja
07-16-2012, 07:20 AM
Aloy78,
I think this is what you want. See attached code. When you click search record no button (commandbutton1), it searches the appropriate sheet for the record, and if found fills the data on the userform. if not found it gives a message box. When you save record (click cmdAdd), it saves it to the appropriate record.

On another note, you really need to look at your original design. You should be naming the controls things that make sense... IE don't name text box associated with record no as txtCnee, name it txtRecordNo and don't name text box associated with Date txtAdd1, name it txtDate, dont name search record no commandbutton1, name it cmdSearchRecordNo. When you look at this code 3 years from now, it will not make sense to you unless you fix these things. I kept with your naming convention, but you should really fix this as I am certain it will burn you badly in the future.

I hope this is of help to you and what you were looking for.

aloy78
08-02-2012, 11:13 PM
Hi CodeNinja,

Thanks for the reference and tips on the naming convention. I'll give this a try :)