This topic is locked

Event

2/21/2006 10:39:44 AM
ASPRunnerPro General questions
T
techno author

Hi, Sergey:

I am testing your ASPRunnerPro4 and it looks great.
I am trying to use the delete function to add a record to a different table. (I will change the wording "delete selected" at a later time. I have it working where it does NOT delete the record in the table and DOES at a new record to the other table. However, it is only adding the key auto number field. I cannot figure out how to get the other fields in the 2nd table to update from the original table.
Scenario
First table includes a songid and songtitle - when I click the delete checkbox next to the record that I want to delete (which i am adding to the 2nd table) it processes my request (does not delete the record because I have the BeforeDelete = false) but does NOT enter the songid and songtitle into the second table only adds the key field (auto number)
How do I get the songid and songtitle into the 2nd table for a particular client and be sure that I don't delete the original record.. is this possible? I can't figure any other way to have an Add page where you can select multiple records.
Thanks,

Marie

Sergey Kornilov admin 2/21/2006

Marie,
to copy records to another table you need to build appropriate SQL query. In BeforeDelete Event use Save old data record in another table action.

Function BeforeDelete(where)
' Parameters:

' where - string with WHERE clause pointing to record to be deleted.
'********** Save old data record in another table ************

strSQLSave = "INSERT INTO SecondTable (Field1, Field2) SELECT Field1, Field2 FROM " & strTableName & where

dbConnection.Execute strSQLSave
BeforeDelete = False
' set BeforeDelete to True if you like to proceed with deleting record

' set it to False in other case
End Function
T
techno author 2/21/2006

Marie,

to copy records to another table you need to build appropriate SQL query. In BeforeDelete Event use Save old data record in another table action.

Function BeforeDelete(where)
' Parameters:

' where - string with WHERE clause pointing to record to be deleted.
'********** Save old data record in another table ************

strSQLSave = "INSERT INTO SecondTable (Field1, Field2) SELECT Field1, Field2 FROM " & strTableName & where

dbConnection.Execute strSQLSave
BeforeDelete = False
' set BeforeDelete to True if you like to proceed with deleting record

' set it to False in other case
End Function


Thanks for replying Sergey - However do I change the name of Field1, Field2 and what do I do with the where... do I change strTableName

If I set the BeforeDelete = False, can I be certain that it will NOT delete the record in the first table?

Thanks for your help. I have tried every which way and can only get it to add a new record (autonumber field) but not other fields.
Regards,

Marie

Sergey Kornilov admin 2/21/2006

Replace Field1, Field2 with actual field names. Replace SecondTable with actual name of sceond table. Do not touch strTableName. Set BeforeDelete = False to make sure records are not deleted.