This topic is locked

Checking for Specific 'Authorization'

2/1/2007 11:58:33 PM
ASPRunnerPro General questions
K
kconzel author

Any help would be greatly appreciated.

I'm trying to use the "Before Record Added" event in a Time_Card_Query.

I've created a field in the query called TCCID: EmployeeID+Campus+Month.

If the TCCID has been "authorized" in "QryAuthorizations" and has an AuthorizationCID (EmployeeID+Campus+Month), I would like it to be set so you can't add to that person's month's campus' data. Is this possible?

I'm very new to ASP and don't know how to do the custom code part.
The error given is:select * from QrySAuthorizations where AuthCID =''
<<< Record was NOT updated >>>
[Microsoft][ODBC Microsoft Access Driver]Error in row
Here's the code I was trying to use....
Function BeforeAdd(dict)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form represented as 'Field name'-'Field value' pair
'** Check if specific record exists ****

strSQLExists = "select * from QrySAuthorizations where AuthCID ='" & dict("TCCID") & "'"
set rsExists = CreateObject("ADODB.Recordset")

Response.write strSQLExists

rsExists.Open strSQLExists, dbConnection

if not rsExists.eof then

Response.write "This Campus/User/Month has already been authorized."

BeforeAdd=False

else

' if dont exist do something else
end if

rsExists.Close : set rsExists = Nothing
BeforeAdd = True
' set BeforeAdd to True if you like to proceed with adding new record

' set it to False in other case
End Function

J
Jane 2/2/2007

Hi,
you can't use field you've added on the Edit SQL query tab in the select query in your events because this field doesn't exist in the database.

Try to use the following query:

strSQLExists = "select * from QrySAuthorizations where EmployeeID =" & dict("EmployeeID") & " and Campus='" & dict("EmployeeID") & "' and Month='" & dict("Month") & "'"



Also you need to remove TCCID field from the ADD/EDIT page on the Choose fields tab.

K
kconzel author 2/2/2007

Works like a charm. Always seems like I ask "duh" questions.

Thanks for all your help.

Y'all are incredible!!!!!!!!

Hi,

you can't use field you've added on the Edit SQL query tab in the select query in your events because this field doesn't exist in the database.

Try to use the following query:
Also you need to remove TCCID field from the ADD/EDIT page on the Choose fields tab.