Consulting

Results 1 to 4 of 4

Thread: Userform to edit records in different sheets

  1. #1
    VBAX Regular
    Joined
    Aug 2011
    Posts
    60
    Location

    Userform to edit records in different sheets

    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.
    Attached Files Attached Files

  2. #2
    VBAX Mentor
    Joined
    Apr 2009
    Location
    Kingsbury
    Posts
    423
    Location
    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.

  3. #3
    VBAX Tutor
    Joined
    Jun 2012
    Posts
    269
    Location
    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.
    Attached Files Attached Files

  4. #4
    VBAX Regular
    Joined
    Aug 2011
    Posts
    60
    Location
    Hi CodeNinja,

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •