Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: How to capture original database fields and compare form field changes to it


Message #1 by "Larry Rosenzweig" <rosenzl@o...> on Thu, 31 Jan 2002 14:42:49
I have an application that has a page that displays a date, start time and 

end time. If you change any of them on the page, it inserts or updates 

various Access tables. As a result of this, when the date changes on the 

page, the logic checks to see if that date exists in the database. If it 

does not, then a new record is created. The problem is that I must delete 

the old record that has the original date. So I must capture the original 

date, before it was changed, so I can delete the original table record, 

after the new record is inserted. Is there something like a first time 

routine? 



Thanks,



Larry  
Message #2 by btodd@a... on Thu, 31 Jan 2002 17:26:02
How about storing the original values in a session variable? You could 

then retrieve the value inside your create logic and do the delete. Using 

VBScript, something like this:

===============

'first read 

Session("origDate") = RS.origDate 'change to your var name/RS name

===============



'create logic

' your current logic to create record with new date



vSQL = "DELETE * FROM your table name"

vSQL = vSQL & " WHERE (your table name.origDate=" & Session("origDate") 

& ")"

Set RS = objConnection.Execute(vSQL) 

'change objConnection to whatever name you use



'error checking

IF err <> 0 THEN

'whatever you need to do if the delete didn't work

END IF

=======================



Hope this helps,

 Bill



> I have an application that has a page that displays a date, start time 

and 

> end time. If you change any of them on the page, it inserts or updates 

> various Access tables. As a result of this, when the date changes on the 

> page, the logic checks to see if that date exists in the database. If it 

> does not, then a new record is created. The problem is that I must 

delete 

> the old record that has the original date. So I must capture the 

original 

> date, before it was changed, so I can delete the original table record, 

> after the new record is inserted. Is there something like a first time 

> routine? 

> 

> Thanks,

> 

> Larry  
Message #3 by btodd@a... on Thu, 31 Jan 2002 17:44:40
CORRECTION

> Session("origDate") = RS.origDate

should be RS("origDate") 

  Return to Index