Charon.co.uk Forums Charon.co.uk   Home   Search   Login   Register   Member List  
Support  > Articles  > Update multiple records AND post to 2 tables  
 
Display using:  
Previous Thread :: Next Thread 
 Author Thread: Update multiple records AND post to 2 tables
pssully2000 is not online. Last active: 3/4/2008 7:24:47 AM pssully2000
Joined: 03 Mar 2008
Total Posts: 2
 
Update multiple records AND post to 2 tables
Posted: 03 Mar 2008 05:52 AM
Hi Julian,

I'm a big fan of your site and have been for a couple of years. I have the following code which is working very well:

<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
st.Movenext
wend
response.redirect "Admin.asp"
end if
%>

However, I would also like to write the same recordset to another table. I tried the following code but it's not working:
<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
st.Movenext
wend
keeptrack.AddNew
keeptrack("Amend_Date")=Request("DateofAmend")
keeptrack("ID_Short")=Request(st.Fields.Item("ID_Short").Value)
keeptrack.Update
response.redirect "Admin.asp"
end if
%>

Can you tell me where I'm going wrong?

With thanks,

Pat from UK
pssully2000 is not online. Last active: 3/4/2008 7:24:47 AM pssully2000
Joined: 03 Mar 2008
Total Posts: 2
 
Re: Update multiple records AND post to 2 tables
Posted: 04 Mar 2008 05:58 AM
UPDATE:
I have this code now working - but it is only writing one record at a time to the table via the "enter" recordset (even though I am doing batch update).

How to write ALL batch updates to a second table? Pulling out my hair on this one.

<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
st.Movenext
wend
end if
%>
<%
if Request("selected") <> "" Then
enter.AddNew
enter("Amend_Date")=Request("Amend_Date")
enter("Colour1")=Request("Colour1" & ID_Unique)
enter("Stock")=Request("Stock" & ID_Unique)
enter.Update
Response.Redirect("Admin.asp")
end if
%>
Admin is not online. Last active: 3/26/2009 7:35:11 AM Admin
www.charon.co.uk
Top 25 Poster
Forum Moderator
Joined: 18 Aug 2003
Total Posts: 2652
 
Re: Update multiple records AND post to 2 tables
Posted: 09 Mar 2008 05:01 PM
You'd need to combine the snippets. ie

<%
if request("selected") <> "" Then
st.MoveFirst
while not st.eof
ID_Unique=st("ID_Unique")
st("Colour1")=Request("Colour1" & ID_Unique)
st("Stock")=Request("Stock" & ID_Unique)
st.update
enter.AddNew
enter("Amend_Date")=Request("Amend_Date")
enter("Colour1")=Request("Colour1" & ID_Unique)
enter("Stock")=Request("Stock" & ID_Unique)
enter.Update
st.Movenext
wend
end if
%>
<%
if Request("selected") <> "" Then

Response.Redirect("Admin.asp")
end if
%>

Julian Roberts

Site Administrator
Previous Thread :: Next Thread 
Page 1 of 1
 
Charon.co.uk Forums  > Support  > Articles  > Update multiple records AND post to 2 tables