C
|
clig 2/18/2007 |
I have a Time Card table and an authorization table with EmpKey, Month and Campus, actually the field names are: TblTimeCard: EmpKey, MonthTC, and CampusTC and QryAuthorizations: EmpKey, MonthAuth, and CampusAuth. Anything that has been "authorized" by month and campus cannot be edited/added to or deleted from. I'd like to use an Onload Event but I can't figure that out so I'm trying to set up a "Before Delete Function" Here's the code. Please, please do you have any idea what I'm doing wrong? (And also how to set up the Edit Onload Event) On the TblTimeCard_list.asp page - Events tab Function BeforeDelete(where) ' Parameters: ' where - string with WHERE clause pointing to record to be deleted. set rstmp = Server.CreateObject("ADODB.Recordset") rstmp.Open "select * from QryAuthorizations where EmpKey='" & EmpKey & "' and CampusAuth='" & CampusTC & "' and MonthAuth='" & MonthTC & "'", dbConnection if rstmp.eof then BeforeDelete = True else BeforeDelete = False response.write "This campus/month's time has already been authorized and no entries can be changed or deleted" end if rstmp.Close : set rstmp = nothing End Function Any help would be greatly appreciated.
|
J
|
Jane 2/19/2007 |
Hi, str = "select from " & strTableName & " where " & where set rsInfo = Server.CreateObject("ADODB.Recordset") rsInfo.Open str,dbConnection set rstmp = Server.CreateObject("ADODB.Recordset") rstmp.Open "select from QryAuthorizations where EmpKey='" & rsInfo("EmpKey") & "' and CampusAuth='" & rsInfo("CampusTC") & "' and MonthAuth='" & rsInfo("MonthTC") & "'", dbConnection |
K
|
kconzel author 2/19/2007 |
I tried it using your sample for the Before Delete and it still didn't work. Hi, you need to pull all values from TblTimeCard table and then compare these values with values from the QryAuthorizations table. Here is a sample: |
J
|
Jane 2/20/2007 |
Variable strTableName contains table name of the current table. So you don't need to replace it with your actual table name: ... str = "select * from " & strTableName & " where " & where set rsInfo = Server.CreateObject("ADODB.Recordset") rsInfo.Open str,dbConnection ... |