From: Si on
I get the following error from the code below:

Error Type: (0x80020009)
Exception occurred.
/diary.asp, line 53


The specific part that causes the exception is when I try to access
rsAppsTemp("AppointmentDate") in the While loop. For some reason it works
fine in the If statement above it, but not in the While loop.

Any ideas?


=========

Function DiaryEntry(DBDate, LoopDate, HourVal, rsAppsTemp)
If IsDate(rsAppsTemp("AppointmentDate")) And IsNumeric(LoopDate) And
IsNumeric(HourVal) And Not rsAppsTemp.EOF Then 'validate input
If Day(rsAppsTemp("AppointmentDate")) = LoopDate Then ' LoopDate is a
date value representing day of month from 1 to 31
If CInt(Hour(rsAppsTemp("AppointmentDate"))) = CInt(HourVal) Then '
HourVal represents the hour from 0 to 23
While CInt(Hour(rsAppsTemp("AppointmentDate"))) = CInt(HourVal) 'THIS
IS LINE 53
Response.write rsAppsTemp("Postcode") & " (" &
ShortenString(rsAppsTemp("BusinessName"), 10) & ") " & "<br/>"
rsAppsTemp.MoveNext
Wend
Else
Response.write "&nbsp;"
End If
End If
End If
End Function




From: Bob Barrows [MVP] on
Si wrote:
> I get the following error from the code below:
>
> Error Type: (0x80020009)
> Exception occurred.
> /diary.asp, line 53
>
Do any of the possibilities in this article apply?
http://www.aspfaq.com/show.asp?id=2421

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


From: Bob Barrows [MVP] on
Si wrote:

>
> Function DiaryEntry(DBDate, LoopDate, HourVal, rsAppsTemp)

This is extremely poor programming practice. When using a value from an
object more than once, assign the value to a variable.

dim appt
appt=rsAppsTemp("AppointmentDate").value

Now go through your subsequent code in this function and replace
rsAppsTemp("AppointmentDate") with appt. Your problem will be resolved.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


From: Si on
"Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message
news:eapaEcMMGHA.3728(a)tk2msftngp13.phx.gbl...
> Si wrote:
>> I get the following error from the code below:
>>
>> Error Type: (0x80020009)
>> Exception occurred.
>> /diary.asp, line 53
>>
> Do any of the possibilities in this article apply?
> http://www.aspfaq.com/show.asp?id=2421

I'm fairly certain they don't.

I'm probably wrong but I suspect that the exception is somehow due to the
fact that the "AppointmentDate" field data cannot be accessed from the
rsAppsTemp recordset due to the MoveNext applied to it within the loop. I
reckon it is failing after one iteration of the loop, but I just don't know
how to get round the problem.


From: Si on
"Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message
news:etLlGeMMGHA.2916(a)tk2msftngp13.phx.gbl...
> Si wrote:
>
>>
>> Function DiaryEntry(DBDate, LoopDate, HourVal, rsAppsTemp)
>
> This is extremely poor programming practice. When using a value from an
> object more than once, assign the value to a variable.

I'm aware that this isn't a good idea, but I have been trying various
methods to get round this problem and as a consequence my code is in a bit
of a mess.

> dim appt
> appt=rsAppsTemp("AppointmentDate").value
>
> Now go through your subsequent code in this function and replace
> rsAppsTemp("AppointmentDate") with appt. Your problem will be resolved.

But then the problem with that is that rsAppsTemp("AppointmentDate") which
is used in the While loop will not be updated with the rsAppsTemp.MoveNext.
In other words it will stay the same and the loop will continue until EOF.