Greetings,
I am new to this site and am in hopes that someone can help me out with a problem I am having. I have a calendar that was built by someone else that I need to slightly modify. The guy who built this calendar is an asp genius but I can not find him, I have not had contact with him for over 5 years and I need to modify this page. I am not ASP illiterate but I am no genius either. The issue is trying to loop through the recordset, but I need to loop through twice. Is that possible and if so can anyone help me with the code? Here is what I want to do... The calendar is quite simple, it displays the days of the week and it a date has an event associated with it then it displays an image on that date. What I want to do is to have the image changed according to a yes/no value in a separate field in the database. The code that loops through now is...

<% PutImage = "False" %>
<% If Not QResults.EOF Then %>
<% Do While CurrentNumber = Day(QResults("StartDate")) %>
<% PutImage = "True" %>
<% QResults.MoveNext %>
<% If QResults.EOF Then %>
<% Exit Do %>
<% End If %>
<% Loop %>
<% End If %>

The above code works wonderfully...

Now I want to make PutImage be one image if it is an event and another image if the date is booked to capacity. I have a field in the database called Booked with a yes/no value. I have tried to do a simple if statement like this...

<% if (QResults("Booked")) = "True" Then %>
<img src="<%= BookedImage %>" border="0"></a>
<% else %><img src="<%= EventImage %>" border="0"></a>
<% end if %>

But as you can suppose I get the error error '80020009' Exception Occured at the last record that has a value.Upon further researching this error I have found that it is caused by not looping through the recordset. If anyone can be of assistance I would greatly appreciate it.

Thanks
JW

Try this. You can change the 'condition' to display images you like
<%
PutImage = "False"
' looping
While Not QResults.EOF
' condition
if CurrentNumber = Day(QResults("StartDate")) Then
PutImage = "True"
end If
' move to next record
QResults.MoveNext
WEND
%>

Try this. You can change the 'condition' to display images you like
<%
PutImage = "False"
' looping
While Not QResults.EOF
' condition
if CurrentNumber = Day(QResults("StartDate")) Then
PutImage = "True"
end If
' move to next record
QResults.MoveNext
WEND
%>

Thank you for replying. I tried the above but it did not work so I am pasting the entire code for the page from that point to the end and hopefully this will help, sorry I didn't do that in the first place. What happens when I try your suggestion is I get no image on the page, it is like putimage is not being populated for some reason, not sure why. I appreciate your help with this.

Thanks again,
JW

<% PutImage = "False" %>
<% If Not QResults.EOF Then %>
<% Do While CurrentNumber = Day(QResults("BookedDate")) %>
<% PutImage = "True" %>
<% QResults.MoveNext %>
<% If QResults.EOF Then %>
<% Exit Do %>
<% End If %>
<% Loop %>
<% End If %>

<% If PutImage = "True" Then %>
<a href="EventDetail.asp?EventDate=<%= cdate(CurrentMonth & "/" & CurrentNumber & "/" & CurrentYear) %>" onClick="return MM_openBrWindow('EventDetail.asp?EventDate=<%= cdate(CurrentMonth & "/" & CurrentNumber & "/" & CurrentYear) %>','','scrollbars=yes,menubar=yes,width=600,height=300')">
<img src="<%= EventImage %>" border="0"></a>
<br>
<% Else %>
<% End If %>

<%= CurrentNumber %>
<% Else %>
</font>
</small>
</small>
</td>
<td width="14%" align="right" valign="bottom"><small><small><font face="Verdana, Arial, sans-serif">&nbsp;<br>
&nbsp; <% NoMore = "True" %> <% End If %> <% Else %> </font></small></small></td>
<td width="14%" height="19" align="right" valign="bottom"><small><small><font face="Verdana, Arial, sans-serif">&nbsp;<br>
&nbsp; <% End If %> <% CurrentNumber = CurrentNumber + 1 %> </font></small></small></td>
<% Next %>
</tr>
<% If NoMore = "True" Then %>
<% Exit For %>
<% End If %>
<% Next %>
</table>
</td>
</tr>
</table>
<% QResults.Close %>
<% DBConn.Close %>
</td>
</tr>
</table>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.