|
-
Dec 12th, 2013, 06:26 PM
#1
Thread Starter
Fanatic Member
[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
-
Dec 12th, 2013, 11:19 PM
#2
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
-
Dec 13th, 2013, 11:09 AM
#3
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|