bjones
06-16-2005, 12:25 PM
I working with an event calendar and am trying to display each event in a diferent color. I have the single events for a particular date working fine, but am stumbling when it comes to multiple events on the same day.
What's happening is all the events for that day display in one color, instead of different colors assigned for each event (the color chosen seems to be the first color extracted from the DB)
The functionality is when a user is scheduling an event they choose a color from a drop-down of approx. 5 colors, then that information is stored in an access DB along with the event.
I've included the relevant code below. As stated there is additional code for the "single" events, but its working fine and not relevant to this problem.
*** CODE ***
TQL = "SELECT Type FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
RQL = "SELECT event FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
SQL = "SELECT count(*) As mycount " & _
"FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
PQL = "SELECT event FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
Set RS = oConn.execute(SQL)
Events = RS("mycount")
Mevents = RS("mycount")
Set RS = nothing
Set BS = oConn.execute(RQL)
Set GS = oConn.execute(TQL)
Set VS = oConn.execute(PQL)
Do While Not BS.EOF
if Events > 1 then
for each x in BS.fields
ECount=(x.value)
next
for each y in GS.fields
Etype=(y.value)
If Etype = "green" then
Send "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?d=1&date=" & Server.URLEncode(DateString) & """><font color=0C9802>" & ECount & "</a><br>"
Else
Send "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?d=1&date=" & Server.URLEncode(DateString) & """><font color=000000>" & ECount & "</a><br>"
end if
next
End If
BS.MoveNext
Loop
*** END CODE ***
This code is slightly incomplete as I haven't added the "if" statements for the additional colors yet. But for the purposes of testing it should still work and either display each event in green or black. As I said previously though the color displayed seems to be the color stored in the first event taken from the DB. (example: If the color stored in the first event is green then all events for that day display in green, if its black then all events for that day display in black, ETC)
I am somewhat new to this level of coding so please don't bash my code abilities too badly.
Any help would be appreciated.
Thanks
Bjones
What's happening is all the events for that day display in one color, instead of different colors assigned for each event (the color chosen seems to be the first color extracted from the DB)
The functionality is when a user is scheduling an event they choose a color from a drop-down of approx. 5 colors, then that information is stored in an access DB along with the event.
I've included the relevant code below. As stated there is additional code for the "single" events, but its working fine and not relevant to this problem.
*** CODE ***
TQL = "SELECT Type FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
RQL = "SELECT event FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
SQL = "SELECT count(*) As mycount " & _
"FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
PQL = "SELECT event FROM events " & _
"WHERE month(scheduledDate) = " & month(DateString) & " " & _
"AND day(scheduledDate) = " & day(DateString) & " " & _
"AND year(scheduledDate) = " & year(DateString) & ";"
Set RS = oConn.execute(SQL)
Events = RS("mycount")
Mevents = RS("mycount")
Set RS = nothing
Set BS = oConn.execute(RQL)
Set GS = oConn.execute(TQL)
Set VS = oConn.execute(PQL)
Do While Not BS.EOF
if Events > 1 then
for each x in BS.fields
ECount=(x.value)
next
for each y in GS.fields
Etype=(y.value)
If Etype = "green" then
Send "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?d=1&date=" & Server.URLEncode(DateString) & """><font color=0C9802>" & ECount & "</a><br>"
Else
Send "<a href=""" & Request.ServerVariables("SCRIPT_NAME") & "?d=1&date=" & Server.URLEncode(DateString) & """><font color=000000>" & ECount & "</a><br>"
end if
next
End If
BS.MoveNext
Loop
*** END CODE ***
This code is slightly incomplete as I haven't added the "if" statements for the additional colors yet. But for the purposes of testing it should still work and either display each event in green or black. As I said previously though the color displayed seems to be the color stored in the first event taken from the DB. (example: If the color stored in the first event is green then all events for that day display in green, if its black then all events for that day display in black, ETC)
I am somewhat new to this level of coding so please don't bash my code abilities too badly.
Any help would be appreciated.
Thanks
Bjones