J
|
Jane 3/24/2009 |
Hi, str = "select * from TableName where FieldName='" & dict("FieldName") & "'" Set rstmp = server.CreateObject("ADODB.Recordset") rstmp.open str,dbConnection if not rstmp.eof then response.write "a record for the date selected already exists in the database" BeforeAdd = False rstmp.close set rstmp=nothing BeforeAdd = True |
S
|
sunnynayak author 3/24/2009 |
Hi, use Before record added event on the Eventstab for this purpose. Here is a sample:
|
J
|
Jane 3/25/2009 |
Hi, str = "select * from TableName where FieldName1='" & dict("FieldName1") & "' and FieldName2='" & dict("FieldName2") & "'" |
S
|
sunnynayak author 3/26/2009 |
I entered the code <% ' Before record added Function BeforeAdd(dict,message,inline) ' Parameters: ' dict - Scripting.Dictionary object. ' Each field on the Add form is represented as a 'Field name'-'Field value' pair '** Custom code **** ' put your custom code here str = "select * from Worklog where Name='" & dict("Name") & "' and Date='" & dict("Date") & "'" Set rstmp = server.CreateObject("ADODB.Recordset") rstmp.open str,dbConnection if not rstmp.eof then response.write "A record for the date selected already exists in the database" BeforeAdd = False rstmp.close set rstmp=nothing BeforeAdd = False ' set BeforeAdd to True if you like to proceed with adding new record ' set it to False otherwise End Function ' BeforeAdd %>
Microsoft VBScript compilation error '800a03f4' Expected 'If' /training/portal/include/Worklog_events.asp, line 27 End Function ' BeforeAdd ----^ |
J
|
Jane 3/27/2009 |
Sorry for my fault. str = "select * from Worklog where Name='" & dict("Name") & "' and Date='" & dict("Date") & "'" Set rstmp = server.CreateObject("ADODB.Recordset") rstmp.open str,dbConnection if not rstmp.eof then response.write "A record for the date selected already exists in the database" BeforeAdd = False else BeforeAdd = True end if rstmp.close set rstmp=nothing |