Forum Moderators: open

Message Too Old, No Replies

Multi Record Update in Access from one form

Is this possible?

         

Hobnob

10:12 pm on Dec 18, 2003 (gmt 0)

10+ Year Member



Hi,

Is it possible to update multiple records from a recordset using 1 form with ASP and Access? If so do you know where I could find a tutorial?

Thanks

John

TheNige

12:49 am on Dec 19, 2003 (gmt 0)

10+ Year Member



You can loop through your form data and call the update to Access each time by just changing your SQL to update the appropriate rows.

Hobnob

9:50 am on Dec 19, 2003 (gmt 0)

10+ Year Member



Can you explain how i do this - or point me to a tutorial? Many Thanks.

ziggystardust

12:06 pm on Dec 21, 2003 (gmt 0)

10+ Year Member



Hello Hobnob,

looping and updating could be as simple as this:

For i = 1 To 5
sqlString = "UPDATE yourTable SET tableRow = '" & someValue & "' WHERE anotherRow = " & i
' execute the sqlString
Loop

It's a pretty useless query but it shows that looping isn't really that hard. Since we don't know what your form looks like or what it does, It's kinda hard to know if a For-loop will solve your problem.

Hmm, on the other hand, If the question was whether you can update multiple records in Access using just one (1) action, then the answer is both yes and no.

Yes, if the rows you want to update are all in the same table and should be updated with the same values. In that case you'd be able to use several WHERE clauses nestled together with an AND or/and an OR: ;)

sqlString = "UPDATE yourTable SET tableRow = '" & someValue & "' WHERE anotherRow = '" & anotherValue & "' OR anotherRow = '" & yetAnotherValue & "'"

No, if you want to update different tables or update different rows in the same table. As far as I know, Access does not support executing multiple SQL queries in the same "action" ie:

sqlString = "UPDATE yourTable SET tableRow = 5; UPDATE yourTable SET otherRow = 6"
'Execute the query

This won't work in Access. You have to separate the queries and execute each one separately.

I probably haven't provided you with a complete solution here but, hopefully, it was a start. :)

A couple of good site where you can find ASP tutorials:
[4guysfromrolla.com...]
[asp101.com...]
[aspin.com...]

Good luck
//ZS