Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is my "End If" positioned correctly?

Status
Not open for further replies.

roaml

Technical User
Feb 19, 2002
264
US
Hello, Can anyone help me with this?

I need to know what I am doing wrong with my code. I have an input form and the form is pulling from two tables, a wo_table and a project_table. I am calling a work order number from a report list and the input form appears. Now the problem, the form opens and displays the data from the wo_table (this is good), but it only displays the “Builder Information” title and no input fields. I know this is because there are no records matching the work order number I pulled from the wo_table. I am sure there is a way to output empty records.

I am in desperate need of help and appreciate your support. My code is listed below.


<%@ LANGUAGE=&quot;vbscript&quot; %>
<% set Dataconn = server.CreateObject(&quot;ADODB.Connection&quot;)
Dataconn.Open &quot;Data Source=wa-prodserv;Provider=SQLOLEDB; Initial Catalog=wotable;User ID=wouse;Password=special6&quot;
session(&quot;wo_number&quot;) = Request.QueryString(&quot;RecordID&quot;)

msql = &quot;SELECT * FROM wo_table where wo_number=&quot; & Request.QueryString(&quot;RecordID&quot;)
Set RS = DataConn.Execute(msql)
%>

<html>
<head>
<title> Work Order Request</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;>
<LINK href/project/css/project.css&quot; rel=stylesheet type=&quot;text/css&quot;>
<SCRIPT LANGUAGE=&quot;JavaScript&quot; SRC=&quot;/project/CalendarPopup.js&quot;></SCRIPT>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>document.write(CalendarPopup_getStyles());</SCRIPT>
<SCRIPT language=&quot;JavaScript1.2&quot; src=&quot;/project/validation.js&quot;></SCRIPT>
</HEAD>

<BODY aLink=#003366 bgColor=#ffffff
leftMargin=4 valign=&quot;center&quot; link=#003366 topMargin=3 vLink=#003366 marginheight=&quot;0&quot; marginwidth=&quot;0&quot;>

<form method=&quot;post&quot; action=&quot;post_db.asp&quot; name=&quot;WOForm&quot; id=&quot;WOForm&quot;>
<input type=&quot;hidden&quot; name=&quot;status&quot; value=&quot;Build Completed&quot; size=&quot;20&quot;>
<input type=&quot;hidden&quot; name=&quot;builder_name&quot; value=&quot;<%=RS(&quot;builder_name&quot;)%>&quot;>
<input type=&quot;hidden&quot; name=&quot;wo_number&quot; value=&quot;<%=RS(&quot;wo_number&quot;)%>&quot;>
<div align=&quot;center&quot;>
<center>

<table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#6699CC&quot; border=&quot;2&quot; width=&quot;98%&quot;>
<tr>
<td valign=&quot;top&quot; bgcolor=&quot;#E5E5E5&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bgcolor=&quot;#6699CC&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot;>
<tr>
<td style=&quot;border-style: none; border-width: medium&quot; bgcolor=&quot;#3F7DBC&quot; colspan=&quot;2&quot; height=&quot;20&quot;>
Work Request Form: Development</td>
<td style=&quot;border-style: none; border-width: medium&quot; bgcolor=&quot;#3F7DBC&quot; height=&quot;20&quot; align=&quot;right&quot;> Request Date: <%=RS(&quot;submit_date&quot;)%> </td>
</tr>
<tr>
<td style=&quot;border-style: none; border-width: medium&quot; align=&quot;center&quot;>
Work Order Number: <%=RS(&quot;wo_number&quot;)%> </td>
<td style=&quot;border-style: none; border-width: medium&quot; align=&quot;center&quot;>
Status: <%=RS(&quot;status&quot;)%> </td>
<td style=&quot;border-style: none; border-width: medium&quot; align=&quot;center&quot;>
Priority: <%=RS(&quot;priority&quot;)%>
</STRONG></td>
</tr>
</table></td>
</tr>
<tr>
<td style=&quot;border-style: none; border-width: medium&quot; valign=&quot;top&quot; >
<table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bordercolor=&quot;##003366&quot; style=&quot;border-width:0; border-collapse: collapse&quot; width=&quot;100%&quot;>
<tr>
<td align=&quot;center&quot; style=&quot;border-style:none; border-width:medium; &quot; bgcolor=&quot;#E5E5E5&quot; valign=&quot;top>
<table border=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot;>
<tr>
<td colspan=&quot;2&quot; height=&quot;1&quot; > </td>
</tr>
<tr>
<td colspan=&quot;2&quot; ></td>
</tr>
<tr>
<td colspan=&quot;2&quot;><li class=&quot;bullettext&quot;><strong> REQUESTER INFORMATION</strong></td>
</tr>
<tr>
<td width=&quot;20&quot;> </td>
<td >

<table border=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot; >
<tr>
<td width=&quot;300&quot; >Name: <%=RS(&quot;requester_name&quot;)%></td>

<td >Buidl Date: <%=RS(&quot;components&quot;)%></td>
</tr>
<tr>
<td width=&quot;300&quot; >Phone Number: <%=RS(&quot;requester_phone&quot;)%></td>

<td >Build Type: <%=RS(&quot;request_type&quot;)%></td>
</tr>
<tr>
<td width=&quot;300&quot; >Department: <%=RS(&quot;requester_department&quot;)%></td>
<td >Completion Date: <%=RS(&quot;required_completion_date&quot;)%>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width=&quot;20&quot;> </td>
<td ><br>
Build Description:<br>
<%=RS(&quot;project_description&quot;)%></td>
</tr>
<tr>
<tr>
\<td colspan=&quot;2&quot;>
<hr color=&quot;#6699CC&quot; size=&quot;1&quot;></td>
</tr>
<tr>

<!-- RELEASE -->
<tr>
<td colspan=&quot;2&quot;><li class=&quot;bullettext&quot;><strong> RELEASE INFORMATION </font> </strong></td>
</tr>

<%
mysql = &quot;SELECT * FROM wo_table where wo_number=&quot; & Request.QueryString(&quot;RecordID&quot;)
Set RS = DataConn.Execute(mysql)
IF not RS.EOF then
%>

<tr>
<td width=&quot;20&quot;> </td>
<td >

<table border=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot; >
<tr>
<td width=&quot;249&quot; >Project Date: <%=RS(&quot;project_date&quot;)%></td>
<td width=&quot;330&quot; >Project Lead: <%=RS(&quot;project_lead&quot;)%></td>
<td >Site: <%=RS(&quot;site&quot;)%></td>
<td width=&quot;160&quot; >Build Date: <%=RS(&quot;build_date&quot;)%></td>
</tr>
</table>
</td>
</tr>
<tr>
<%End IF%>

<!-- BUILDER INPUT SECTION -->
<tr>
<td colspan=&quot;2&quot;>
<hr color=&quot;#6699CC&quot; size=&quot;1&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; > <li class=&quot;bullettext&quot;><STRONG> BUILDER INFORMATION</STRONG></td>
</tr>
<%
mysql = &quot;SELECT * FROM project_table where wo_number=&quot; & Request.QueryString(&quot;RecordID&quot;)
Set DS = DataConn.Execute(mysql)
IF not DS.EOF then

mySQL = &quot;Insert into project_table (wo_number,builder_name,build_start_date,build_completion_date,build_comments) Values('&quot;&wo_number&&quot;','&quot;&builder_name&&quot;','&quot;&build_start_date&&quot;','&quot;&build_completion_date&&quot;','&quot;&build_comments&&quot;');&quot;
%>

<td rowspan=&quot;2&quot; > </td>
<td >Builder Name: <%=DS(&quot;builder_name&quot;)%> Start
Date:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var cal1x = new CalendarPopup(&quot;caldiv1&quot;);
</SCRIPT>
<INPUT TYPE=&quot;text&quot; NAME=&quot;build_start_date&quot; VALUE=&quot;<%=DS(&quot;build_start_date&quot;)%>&quot; SIZE=10 tabindex=&quot;1&quot;>
<A HREF=&quot;#&quot; onClick=&quot;cal1x.select(document.forms[0].build_start_date,'anchor1x','MM/dd/yyyy'); return false;&quot;
NAME=&quot;anchor1x&quot; ID=&quot;anchor1x&quot;><img border=&quot;0&quot; src=&quot;/tsd/images/icons/icon_cordinate.gif&quot; title=&quot;Select Date&quot;></A>
Completed Date:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var cal2x = new CalendarPopup(&quot;caldiv1&quot;);
</SCRIPT>
<INPUT TYPE=&quot;text&quot; NAME=&quot;build_completion_date&quot; VALUE=&quot;<%=DS(&quot;build_completion_date&quot;)%>&quot; SIZE=10 tabindex=&quot;2&quot;>
<A HREF=&quot;#&quot; onClick=&quot;cal2x.select(document.forms[0].build_completion_date,'anchor2x','MM/dd/yyyy'); return false;&quot;
NAME=&quot;anchor2x&quot; ID=&quot;anchor2x&quot;><img border=&quot;0&quot; src=&quot;/tsd/images/icons/icon_cordinate.gif&quot;title=&quot;Select Date&quot;></A></td>
<tr>
<td valign=&quot;top&quot; ><br>Builder Comments:<br>
<textarea rows=&quot;3&quot; name=&quot;build_comments&quot; cols=&quot;100&quot; tabindex=&quot;3&quot;><%=DS(&quot;build_comments&quot;)%></textarea></td>
</tr>
<tr>
<td ></td>
<td ></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;center&quot;> </td>
</tr>
<%End If %>

<!--SUBMIT BUTTON -->
<td colspan=&quot;7&quot; align=&quot;center&quot; >
<input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Submit&quot;>
</td>
</tr>
</table>
</form>
<ID=&quot;caldiv1&quot; STYLE=&quot;position:absolute;visibility:hidden;background-color:white;layer-background-color:white;&quot;>
</center>
</div>
</BODY>
</HTML>
 
A: Is this the entire code you are executing ?
B: By &quot;Builder input fields&quot;, do you mean the Date, type, phone etc ?


&quot;Taxes are the fees we pay for civilized society&quot; G.W.
 
Like I said in the other thread you posted, looks like your html. Create a test page minus the ASP code and see what it does.
Instead of creating a new thread just add a new comment to the old one to keep it on top. Otherwise things get really cluttered. Thanks.
 
If I understand your problem correctly, you page is displaying fine and shows the output BUILDER INFORMATION and then below that shows the Submit button but not the form fields in-between.

If that is in fact the problem, it would indicate that the problem is that you are attempting to get records from the database into the recordset DS and then checking to see if any records were returned with the line:

IF not DS.EOF then

If you do not have any records in the database that will be returned with the SQL statement:

mysql = &quot;SELECT * FROM project_table where wo_number=&quot; & Request.QueryString(&quot;RecordID&quot;)


then the recordset DS will be at the End of File. So if this is the case, then then no lines will be executed between the IF THEN and the END IF statements. This would mean that you Input forms would never be generated.

If you want them to be generated and displayed, even if the recordset is empty, then use variables instead and put the recordset information into the variable if there was a record returned, or an empty string otherwise.


<!-- BUILDER INPUT SECTION -->
<tr>
<td colspan=&quot;2&quot;>
<hr color=&quot;#6699CC&quot; size=&quot;1&quot;></td>
</tr>
<tr>
<td colspan=&quot;2&quot; > <li class=&quot;bullettext&quot;><STRONG> BUILDER INFORMATION</STRONG></td>
</tr>
<%
'create the variables
dim wo_number, builder_name, build_start_date
dim build_completion_date, build_comments

mysql = &quot;SELECT * FROM project_table where wo_number=&quot; & Request.QueryString(&quot;RecordID&quot;)
Set DS = DataConn.Execute(mysql)

IF not DS.EOF then
'Add empty string to end, in case of Null field
wo_number = DS(&quot;wo_number&quot;) & &quot;&quot;
builder_name = DS(&quot;builder_name&quot;) & &quot;&quot;
build_start_date = DS(&quot;build_start_date&quot;) & &quot;&quot;
build_completion_date = DS(&quot;build_completion_date&quot;) & &quot;&quot;
build_comments = DS(&quot;build_comments&quot;) & &quot;&quot;
else
wo_number = &quot;&quot;
builder_name = &quot;&quot;
build_start_date = &quot;&quot;
build_completion_date = &quot;&quot;
build_comments = &quot;&quot;
end if

'Use the variables in your SQL Insert statement, although you don't appear to ever use this???
mySQL = &quot;Insert into project_table (wo_number,builder_name,build_start_date,build_completion_date,build_comments) Values('&quot;&wo_number&&quot;','&quot;&builder_name&&quot;','&quot;&build_start_date&&quot;','&quot;&build_completion_date&&quot;','&quot;&build_comments&&quot;');&quot;

%>

<td rowspan=&quot;2&quot; > </td>
<td >Builder Name: <%=builder_name%> Start
Date:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var cal1x = new CalendarPopup(&quot;caldiv1&quot;);
</SCRIPT>
<INPUT TYPE=&quot;text&quot; NAME=&quot;build_start_date&quot; VALUE=&quot;<%=build_start_date%>&quot; SIZE=10 tabindex=&quot;1&quot;>
<A HREF=&quot;#&quot; onClick=&quot;cal1x.select(document.forms[0].build_start_date,'anchor1x','MM/dd/yyyy'); return false;&quot;
NAME=&quot;anchor1x&quot; ID=&quot;anchor1x&quot;><img border=&quot;0&quot; src=&quot;/tsd/images/icons/icon_cordinate.gif&quot; title=&quot;Select Date&quot;></A>
Completed Date:

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var cal2x = new CalendarPopup(&quot;caldiv1&quot;);
</SCRIPT>
<INPUT TYPE=&quot;text&quot; NAME=&quot;build_completion_date&quot; VALUE=&quot;<%=build_completion_date%>&quot; SIZE=10 tabindex=&quot;2&quot;>
<A HREF=&quot;#&quot; onClick=&quot;cal2x.select(document.forms[0].build_completion_date,'anchor2x','MM/dd/yyyy'); return false;&quot;
NAME=&quot;anchor2x&quot; ID=&quot;anchor2x&quot;><img border=&quot;0&quot; src=&quot;/tsd/images/icons/icon_cordinate.gif&quot;title=&quot;Select Date&quot;></A></td>
<tr>
<td valign=&quot;top&quot; ><br>Builder Comments:<br>
<textarea rows=&quot;3&quot; name=&quot;build_comments&quot; cols=&quot;100&quot; tabindex=&quot;3&quot;><%=build_comments%></textarea></td>
</tr>
<tr>
<td ></td>
<td ></td>
</tr>
<tr>
<td colspan=&quot;2&quot; align=&quot;center&quot;> </td>
</tr>

<!--SUBMIT BUTTON -->
<tr>
<td colspan=&quot;7&quot; align=&quot;center&quot; >
<input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Submit&quot;>
</td>
</tr>
</table>
</form>
<ID=&quot;caldiv1&quot; STYLE=&quot;position:absolute;visibility:hidden;background-color:white;layer-background-color:white;&quot;>
</center>
</div>
</BODY>
</HTML>



Don't forget to set your connection and recordset objects to Nothing when finished, to free up memory.

set DS=nothing




Hope this helps you out.

Bernie


 
Bernlaw, thank you SO much for helping out. You described excactly what I am trying to do and the problem I am having.

I implemented your code and I still get the following error:

Technical Information (for support personnel)

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/projects/wo_form.asp

I am so frustrated that I could cry!!!!

Thanks again.
 
Does the error message give you a line number where the error is actually occuring? This error seems to be happening because you are trying to use a field in the recordset when no information was returned to the recordset. If you can tell what line the error is on, then you can check that line of code specifically to see if it is trying to use a field from the DS recordset.

Bernie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top