View Full Version : Updating Multiple records
StupidRalph
08-04-2003, 11:33 AM
Inquiring about techniques others use to update multiple records in a (2000 Access) db.
I am building a mail system (will post as a free download upon completion if anyone is interested) that has a check all button. I want to be able to update whatever records that are checked.
Please do not tell me that I have to build an array. I was leaning toward building a loop of some sort.
As always just wanted to get feedback b4 i started the script.:)
The basic principle you need to keep in mind, is that this sort of processing envolves some dynamic building in both the form and the processing script. When you buidl the form, the ID's of the records need to be stored as part of the formfields name or values. When running the loop, you then check for the ID-value in the formname or value and use it to build your sql-statement.
If you want to update to the same variable for all selected records, then you need to use a " where ID In ( ) " clause so that you only need to run 1 query. So this query is build before, in and after the loop and executed after the loop
If you want to update to different values, then you need to run a seperate query that is build before and in the loop + executed inside the loop.
i posted some example code here
http://www.codingforums.com/showthread.php?s=&threadid=22753&highlight=for+each+loop+multiple
but if you run some searches on this forum, you'll find some other threads that deal with it.
If you need more speciffic info, you need to specify what sort of update you wanna run.
Roy Sinclair
08-04-2003, 07:54 PM
One thing to keep in mind when updating multiple tables is that if you've got a sitation where all the updates need to go in together or none of the updates occur you should make sure you wrap them in a transaction. If at all possible you should run the entire transaction as a single SQL execute simply to reduce the probability of having a program error leaving you with an incomplete transaction in progress.
StupidRalph
08-05-2003, 01:45 AM
Okay I think that clarifies what I have to do I pretty much figured that.
Sidenote-I am only updating one column in one table.
I just want to change which folder my messages are in. If a message is checked it should update that messages folder to read "trash" instead of "inbox".
I actually did a search and read through 6 pages but I only found a script that appeared to be [perl?]. But I seen your post Raf and I think that will come in handy. In getting me started.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.