Results 1 to 4 of 4

Thread: edit records

  1. #1

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    Lightbulb edit records

    Hi
    i have a small application for payroll.
    While editing and saving records, first i delete the record to be updated and then add new one as edited one. But i think this is not a good logic.
    How can i update only those records which are changed. How can i keep the track of textboxes or comboboxes which are changed?
    Thanks in advance

  2. #2
    russel
    Guest
    r u using ADO to access data? I persume u r using Ms Access to store data. what's the structure of the table u r updating?

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    You can edit a record by using the .Edit method in DAO. In ADO it is not required.

    When you display a record, you already are at the desired record. While saving the information, now, you can use the .Edit method to put the recordset in edit mode, assign new values to the fields, and then .Update the recordset.

    Also I use a global variable Changed which is a boolean to verify if any data was changed or not. In all the Change events of the textboxes, I set this variable to True. At the time of saving, I run the save code only if Changed is True.

    Also if you are using a grid to display multiple records at the same time and allowing the user to edit more than one record at a time, you may create another column in the grid which is hidden, and contains Yes/No based on whether the user changed a particular row or not. And then when saving, go through the recordset checking each record, and using the hidden column you can find out if the record was changed or not.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467
    well the structure is simple like one master and one detail table for one form and database is access.

    I will try method suggested by honeybee and let you know

Posting Permissions

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



Click Here to Expand Forum to Full Width