This topic is locked

Comparison of values Before Add

2/4/2007 12:10:16 AM
ASPRunnerPro General questions
K
kconzel author

This will probably seem like another duh question. I just don't know how to write code.

I have a UIL competition registration that has a maximum number of participants per school per grade per event.

I have a qryPartNumbersRe that has current totals and maximums, along with school, grade and event.

It doesn't matter the values I have in the table so far, it continues to give me the message - This registration was not added. The maximum number of participants has already been reached.

Could you please let me know what I'm doing wrong if it's easy to tell?

Thanks for all your help.
This is the event code so far on my registration_add.asp page.
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 QryPartNumbersRe where event ='" & dict("event") & "' and school='" & dict("school") & "' and grade='" & dict("grade") & "'"
set rsExists = CreateObject("ADODB.Recordset")
rsExists.Open strSQLExists, dbConnection

Response.write strSQLExists

if TotalParts > maximum then

BeforeAdd = True

Response.write "Registration added."

else

BeforeAdd = False

Response.write "This registration was not added. The maximum number of participants has already been reached."

end if

rsExists.Close : set rsExists = Nothing
End Function

Sergey Kornilov admin 2/4/2007

Variables TotalParts and maximum are not defined which makes this code useless.\
Most probably you need to use rsExists("TotalParts") and rsExists("maximum")

K
kconzel author 2/5/2007

Thanks. Worked like a charm!

The support y'all provide is above and beyond any other software.

Thank you so much.

Variables TotalParts and maximum are not defined which makes this code useless.\

Most probably you need to use rsExists("TotalParts") and rsExists("maximum")