Results 1 to 3 of 3

Thread: [RESOLVED] ADO to update MDB records

  1. #1

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Resolved [RESOLVED] ADO to update MDB records

    I've been using Excel VBA and ADO to practice SELECTing and FILTERing records from an MDB file. I used the following code to change values in certain records and was surprised that the MDB file had been updated. Is this normal behavior? I thought the recordset existed in memory only and the UPDATE command was needed to actually save the results to the DB.

    Code:
    rs.Filter = "FIELDA = NULL"
    
    Do While Not rs.EOF
       rs.Fields("FIELDA").Value = rs.Fields("FIELDB").Value
       rs.MoveNext
    Loop

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: ADO to update MDB records

    The answer is "maybe" ... sounds like you had a connected recordset... in which case, yup, when you change something like that and move to the next record, the changes are saved. If the recordset is diconnected, then you could make changes, then connect back to the database and use UpdateBatch to push the changes... either way, you don't need an explicit UPDATE command.. it infers the table schema when you open the recordset... so it can keep track of what rows have been updated.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: ADO to update MDB records

    Thanks, I understand now.

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