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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't code execute

Status
Not open for further replies.

Bastien

Programmer
May 29, 2000
1,683
CA
Hi there

I have the below code snippet and it does not wan to seem to execute properly, I have run an SQL script against a databse and by using invalid dates in the script I returned a null recordset (through TOAD I get "no rows returned") the below code show redisplay the input form and an error message but it seems only to call the CreateReport sub routine


if objTaxWeb.EOF and objTaxWeb.BOF then
strNote = 1 'if null recordset returned
call CreateForm
else
call CreateReport 'call the display function
end if

What am I doing wrong?????

Bastien
 
Bastien,
I'm not all sure what the code is supposed to do, but you can't be at the End of File (EOF) AND Beginning Of File (BOF) at the same time so your first if statement will always be false regardless of your SQL script.

Try using OR instead of AND.
Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
I have tried it with just the .EOF and it still fails...I have also tried
if Server.htmlEncode (objTaxWeb(0)) = "" then

and it doesn't seem to work either...

this problem is extremely frustrating
Bastien
 
This does not work?

if objTaxWeb.EOF then
strNote = 1
call CreateFrom
else
call CreateReport
end if

.htmlEncode takes a string and encodes it into HTML (i.e. fixes non-printable character). It's not used with RecordSet objects and will definatly throw an error if you try that. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
If that doesn't work, could you post some more of your code? The problem may not be with that section. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
here is the whol edamn page. hiding the connection data for self-preservations sake. Thanks for your help



<%
dim strGetTaxInfo, objTaxWeb,x, y, strField, dteStart, dteEnd, strNote
dim strStartMM, strStartDD, strEndDD, strEndMM, strEndYY, strStartYY
%>
<!--#include file=adovbs.inc-->
<%
strEndDD = Request.Form (&quot;EndDD&quot;) 'get the end date
strEndMM = Request.Form (&quot;EndMM&quot;)
strEndYY = Request.Form (&quot;EndYY&quot;)

strStartDD = Request.Form (&quot;StartDD&quot;) 'get the start date
strStartMM = Request.Form (&quot;StartMM&quot;)
strStartYY = Request.Form (&quot;StartYY&quot;)

dteEnd = strEndMM & strEndDD & strEndYY
dteStart = strStartMM & strStartDD & strStartYY

'some validation and checking for the 1st time opening of the form
if not IsDate(dteEnd) and not IsDate (dteStart) then 'if empty then create the form to request the dates
strNote=0
call CreateForm

else
call GetInfo

end if


sub GetInfo()
'create the query

strGetTaxInfo = &quot; select client_code,tax_form, run_flag, last_run_date, send_out_flag, send_out_date &quot;
strGetTaxInfo = strGetTaxInfo & &quot; from tax_status_p_table where tax_year = 2000 and &quot;

if strEnd = StrStart then 'allow for one day
strGetTaxInfo = strGetTaxInfo & &quot; to_char(send_out_date, 'MMDDYYYY') = &quot; & dteStart
else 'date range
strGetTaxInfo = strGetTaxInfo & &quot; to_char(send_out_date, 'MMDDYYYY') >= &quot; & dteStart & &quot; and &quot;
strGetTaxInfo = strGetTaxInfo & &quot; to_char(send_out_date, 'MMDDYYYY') <= &quot; & dteEnd
end if

strGetTaxInfo = strGetTaxInfo & &quot; group by client_code,tax_form, run_flag, last_run_date, send_out_flag, send_out_date&quot;

'set the connection and open that DB for the query
set objTaxWeb = server.createobject(&quot;adodb.recordset&quot;)

objTaxWeb.open strGetTaxInfo, &quot;connection&quot;

Response.Write &quot;EOF is &quot; & objTaxWeb.EOF & &quot; and BOF is &quot; & objTaxWeb.BOF & &quot;<HR>&quot;
if objTaxWeb.EOF then
strNote = 1
call CreateForm
else
call CreateReport 'call the display function
end if

end sub

sub CreateReport()

y= 1 'set the value to control the colour changes in the cell background
Response.Write &quot;<html><head></HEAD><BODY bgcolor = &quot;&quot;cadetblue&quot;&quot;>&quot;
Response.Write &quot;<br><br><center><h1>Tax Slip Status Report</h1></center><br>&quot;

'remind the user of the requested dates for the report
if strStart = strEnd then
Response.Write &quot;You requested the report for the day of <font color = blue>&quot; & dteStart & &quot;</font>&quot;
else
Response.Write &quot;You requested the report for the period from <font color = blue>&quot; & strStart & &quot;</font>&quot;
Response.Write &quot; to <font color = blue>&quot; & dteEnd & &quot;</font>&quot;
end if
'start the table and create the column headers
Response.Write &quot;<br><br><center><table border = 1><th width = 90>Client Code</th><th width = 100>Tax Form</th>&quot;
Response.Write &quot;<th width = 50>Taxes Run</th><th width = 100>Run Date&quot;
Response.Write &quot;</th><th width = 100>Slips Sent Out</th><th width = 100>Date Sent</th>&quot;


'display the results alternating the background colour
do while not objTaxWeb.EOF
if y = 1 then
Response.Write &quot;<tr bgcolor = &quot;&quot;white&quot;&quot;>&quot;
for x = 0 to 5 'cycle through the recordet
set strField =nothing
strField = server.HTMLEncode (objTaxWeb(x))
if x = 2 or x = 4 then 'for true / false boolean values print yes/no
if strField = &quot;1&quot; then
Response.Write &quot;<td>Yes</td>&quot;
elseif strField= &quot;0&quot; then
Response.Write &quot;<td>No</td>&quot;
end if
elseif x = 3 or x = 5 then
strField = FormatDate(strField,2) 'format the date output
Response.Write &quot;<td>&quot; & strField & &quot;</td>&quot;
else
Response.Write &quot;<td>&quot; & strField & &quot;</td>&quot;
end if
next
Response.Write &quot;</tr>&quot;
y=0 'set the cycle up for the next colour

else

Response.Write &quot;<tr bgcolor = &quot;&quot;Silver&quot;&quot;>&quot;
for x = 0 to 5 'cycle through the recordet
set strField =nothing
strField = server.HTMLEncode (objTaxWeb(x))
if x = 2 or x = 4 then 'for true / false boolean values print yes/no
if strField = &quot;1&quot; then
Response.Write &quot;<td>Yes</td>&quot;
elseif strField= &quot;0&quot; then
Response.Write &quot;<td>No</td>&quot;
end if
elseif x = 3 or x = 5 then
strField = FormatDateTime(strField,2) 'format the date output
Response.Write &quot;<td>&quot; & strField & &quot;</td>&quot;
else
Response.Write &quot;<td>&quot; & strField & &quot;</td>&quot;
end if
next
Response.Write &quot;</tr>&quot;
y=1 'set the cycle up for the next colour
end if

objTaxWeb.MoveNext 'cycle through the recordset
loop

'close the table and the connection to the DB
Response.Write &quot;</table><br><br>&quot;
objTaxWeb.Close
Response.Write &quot;<center><input type = button value = &quot;&quot;Another Report&quot;&quot; OnClick = &quot;&quot;BackOne();&quot;&quot; id=button1 name=button1>&quot;
Response.Write &quot;</BODY>&quot;%>
<script language = javascript>
<!--
function BackOne(){
history.back(-1);
}
-->
</script>
</HTML>
<%

end sub


sub CreateForm()

'create the input form to get the dates for the report

Response.Write &quot;<script language = javascript>&quot; & vbcrlf
Response.Write &quot;<!--&quot; & vbcrlf
Response.Write &quot;function Validate(){&quot; & vbcrlf

Response.Write &quot;/*check for valid start/end days, month year */&quot; & vbcrlf
Response.Write &quot;/*start day validation*/&quot; & vbcrlf
Response.Write &quot;if (document.Report.StartDD.value ==&quot;&quot;&quot;&quot; || document.Report.StartDD.value < 0 || document.Report.StartDD.value >31){&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter a VALID number for the Start Day field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.StartDD.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;if (Report.StartDD.value.length != 2) {&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter two digit number for the Start Day field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.StartDD.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;/*start monh validation */&quot; & vbcrlf
Response.Write &quot;if (document.Report.StartMM.value == &quot;&quot;&quot;&quot; || document.Report.StartMM.value < 0 || document.Report.StartMM.value >12){&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter a VALID number for the Month field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.StartMM.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;if (Report.StartMM.value.length != 2) {&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter two digit number for the Start Month field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.StartMM.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;/*start year validation */&quot; & vbcrlf
Response.Write &quot;if (document.Report.StartYY.value == &quot;&quot;&quot;&quot; ||document.Report.StartYY.value <= 2000){&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter a VALID number for the Year field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.StartYY.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;if (Report.StartYY.value.length != 4) {&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter two digit number for the Start Year field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.StartYY.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;/*End day validation */&quot; & vbcrlf
Response.Write &quot;if (document.Report.EndDD.value == &quot;&quot;&quot;&quot; || document.Report.EndDD.value < 0 || document.Report.EndDD.value >31){&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter a VALID number for the End Day field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.EndDD.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;if (Report.EndDD.value.length != 2) {&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter two digit number for the End Day field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.EndDD.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;/*End month validation */&quot; & vbcrlf
Response.Write &quot;if (document.Report.EndMM.value == &quot;&quot;&quot;&quot; || document.Report.EndMM.value < 0 || document.Report.EndMM.value >12){&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter a VALID number for the Month field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.EndMM.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;if (Report.EndMM.value.length != 2) {&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter two digit number for the End Month field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.EndMM.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;/*End year validation */&quot; & vbcrlf
Response.Write &quot;if (document.Report.EndYY.value == &quot;&quot;&quot;&quot; || document.Report.EndYY.value <= 2000 ){&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter a VALID number for the End Year field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.EndYY.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;if (Report.EndYY.value.length != 4) {&quot; & vbcrlf
Response.Write &quot;alert (&quot;&quot;Please enter two digit number for the End Year field&quot;&quot;);&quot; & vbcrlf
Response.Write &quot;document.Report.EndYY.focus();&quot; & vbcrlf
Response.Write &quot;return false;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf

Response.Write &quot;return true;&quot; & vbcrlf
Response.Write &quot;}&quot; & vbcrlf


Response.Write &quot;-->&quot; & vbcrlf
Response.Write &quot;</script>&quot; & vbcrlf

Response.Write &quot;<html><head></HEAD><BODY bgcolor = &quot;&quot;cadetblue&quot;&quot;>&quot;
Response.Write &quot;<center><h2>Tax Status Page</h2></center><br>&quot;
Response.Write &quot;<form name = Report action = ReportStatus.asp method = post onSubmit = &quot;&quot;return Validate();&quot;&quot;>&quot;
Response.Write &quot;<table><tr><td size = 25>Enter Start Date</td><td>&quot;
Response.Write &quot;<input name = StartDD type = text size = 2 maxlength = 2><b>--</b>&quot;
Response.Write &quot;<input name = StartMM type = text size = 2 maxlength = 2><b>--</b>&quot;
Response.Write &quot;<input name = StartYY type = text size = 4 maxlength = 4>&quot;
Response.Write &quot;<tr><td size = 25>Enter End Date</td><td>&quot;
Response.Write &quot;<input name = EndDD type = text size = 2 maxlength = 2><b>--</b>&quot;
Response.Write &quot;<input name = EndMM type = text size = 2 maxlength = 2><b>--</b>&quot;
Response.Write &quot;<input name = EndYY type = text size = 4 maxlength = 4></td>&quot;
Response.Write &quot;<td><input type = submit name = submit value = Submit ></tr></table></form>&quot;

if strNote = 1 then 'warning if start date is greater than end date
Response.Write &quot;<font color = red><h3>No data returned. Please Check your dates.&quot; & vbcrlf
Response.Write &quot;End date cannot be less than Start Date</h3></font>&quot;
end if

Response.Write &quot;<br><br><h3><font color = blue>Please input the dates as DD-MM-YYYY</font></h3>&quot;
Response.Write &quot;</BODY></HTML>&quot;

end sub
 
Hi guys,

It seems that I am dumber than toast. If I build a self-referencing page then the page should refer to itself, right. Well it the code I referred back to an old copy of the file that I was no longer using....

sorry for the confusion...
thanks again

Bastien
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top