I'm trying to check some of the data prior to adding in to a SQL table. An athlete can be registered in up to 4 events and a non-athlete may register as a Unified Partner or a Coach, not both. I get the warnings for each, but on the more than 4 events when I click on "OK" it erases all of the info in the fields but if they are registered as a partner and coach, after I click "OK" the data is still in field.
Here is my code
Function BeforeAdd(dict,message,inline)
'** Too Many Events ****
' Parameters:
' dict - Scripting.Dictionary object.
' Each field on the Add form represented as 'Field name'-'Field value' pair
if (Len(dict("Event01")) = 0) or (Len(dict("Event02")) = 0) or (Len(dict("Event03")) = 0) or (Len(dict("TmEvent01")) = 0) or (Len(dict("TmEvent02")) =0) then
'if IsNull(dict("Event01")) or IsNull(dict("Event02")) or IsNull(dict("Event03")) or IsNull(dict("TmEvent01")) or IsNull(dict("TmEvent02")) then
'** Display a message on the Web page ****
BeforeAdd = True
' set BeforeAdd to True if you like to proceed with adding new record
' set it to False in other case
else
Response.Write "<script>alert('Can Only Register for a TOTAL of 4 Events')</script>"
'Response.write"<font color=""#FF0000"" size= ""4"" >You can only select up to 4 total events</font><BR><BR>"
BeforeAdd = False
end if
'** Partner & Coach Check ****
' put your custom code here
' Parameters:
' dict - Scripting.Dictionary object.
' Each field on the Add form is represented as a 'Field name'-'Field value' pair
Count = 0
if dict("Unified") = 1 and dict("Coach") = 1 then
BeforeAdd = False
'** Display a message on the Web page ****
Response.Write "<script>alert('Individual can be registered as a Coach or as a Unified Partner')</script>"
Else
BeforeAdd = True
End if
' set BeforeAdd to True if you like to proceed with adding new record
' set it to False otherwise
End Function ' BeforeAdd
What am I doing wrong?