PDA

View Full Version : All fine until I add IF condition...


parallon
08-10-2006, 09:54 PM
Hello all. I have a script that works fine until I give it a condition, then I get the following error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/Project/project.asp, line 604

Where line 604 is: Set rsConflict = Nothing

Here is the code, and as soon as I insert the IF and END IF, I get that error (as long as the condition is true).


<%
Dim PhaseAdd

Dim rsConflict
Dim rsConflict_numRows

PhaseAdd = ""
PhaseAdd = Request.QueryString("PhaseAdd")
IF PhaseAdd <> "True" THEN

Set rsConflict = Server.CreateObject("ADODB.Recordset")
rsConflict.ActiveConnection = MM_Tero_Roports_STRING
rsConflict.Source = "SELECT ProjectId, Status, Division, StartDate, EndDate FROM Projects WHERE ((StartDate BETWEEN '" & Start_Date & "' AND '" & End_Date & "' OR EndDate BETWEEN '" & Start_Date & "' AND '" & End_Date & "') OR ('" & Start_Date & "' BETWEEN StartDate AND EndDate OR '" & End_Date & "' BETWEEN StartDate AND EndDate) ) AND (Status <> 'Close' AND Status <> 'COMPLETED' AND Status <> 'Canc')AND Division = '3.VQ.DADA.PM'"
rsConflict.CursorType = 0
rsConflict.CursorLocation = 2
rsConflict.LockType = 1
rsConflict.Open()
rsConflict_numRows = 0


dim PrjID
PrjID=""
while not rsConflict.EOF
PrjID = PrjID & rsConflict("ProjectId") & "\n"
rsConflict.movenext
wend

%>

<script TYPE="text/javascript">

{
var duplicates = "<%=PrjID%>";
if (duplicates) {
alert ("The Project that you are adding has a Start Date and/or End Date within the \n\nStart and End Dates of the following 'OPEN' projects within your division: \n\n" + duplicates);
}

}

</script>
<% End If %>

Here is where the querystring is getting populated:

Response.Write "<SCRIPT LANGUAGE=""JAVASCRIPT"">" & chr(10)
Response.Write "opener.parent.main.document.location.href='project.asp?projectid=" & projectId1 & "&autonum=4&PhaseAdd=True';"
Response.Write "window.close();"
Response.Write "</script>"

Any suggestions would be greatly appreciated.

Thanks,

Parallon

mehere
08-10-2006, 10:12 PM
if this line: Set rsConflict = Nothing
is outside your if/then statement, that will cause that error. and since i'm not seeing it in the code you posted, i can only assume it is.

parallon
08-10-2006, 10:24 PM
That was exactly the problem. See, I use Dreamweaver for a lot of my recordsets, and it has a tendency to put that statement at the end of the page, and up until this point I have never had a problem with this. Now I know. See, you learn something every day. :D

Thank you again for your time,

Parallon