This topic is locked
[SOLVED]

 delete a record when a copy is submitted

2/29/2012 6:22:33 PM
ASPRunnerPro General questions
M
mfred author

Is there any means where I can get ASPRunner to delete a record if a copy of it is submitted?

Sergey Kornilov admin 3/1/2012

I'm not sure what 'copy of it is submitted' means. If you are talking about a duplicate record you can implement BeforeAdd event to check for duplicate and either prevent new record from being added or delete existing one.

M
mfred author 3/2/2012

You got it. If an entry is copied, I want to delete the existing record if the job name matches. I found the code that you referred to. here is what I got. I changed the table name and field to check. I'm not sure about the rest. I need to have the system check the table's JobName against the JobName in the form. If they match, delete the existing record. if they do not match, then just enter the record.
'** Check if specific record exists ****

dim rsExists

set rsExists = dal.GlobalTalentJobArchive.Query("JobName='AnyValue'","")

if not rsExists.eof then

' if record exists do something
else

' if dont exist do something else
end if

rsExists.Close : set rsExists = Nothing

Sergey Kornilov admin 3/2/2012

Try something along these lines. I asusme that you put this code to BeforeAdd event.



dim rsExists

set rsExists = dal.GlobalTalentJobArchive.Query("JobName='" & values("JobName") & "'","")

if not rsExists.eof then

BeforeAdd = False

else

BeforeAdd = True

end if

rsExists.Close : set rsExists = Nothing

Exit Function
M
mfred author 3/6/2012

Thank you.