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

asp and access

Status
Not open for further replies.

tziviak

Technical User
Oct 10, 2002
128
US
I have a calendar that takes information from a table in access
now, the following code-displays the info-but when you click on an event-it just displays the last event
so if I have more than one record for a day-I see all on the calendar-but when I click on any of them-I get directed to the page -with the information for the last record (instead of each line-linking me to that record's information)
each record has an ID-so I'd like to go through that.
any ideas of how I should proceed

here's the code: (I'll give you the whole file-just in case you want to look at other info)
thank you


<%@ LANGUAGE=&quot;VBScript&quot; %>

<%
'Option Explicit
dim calendarname,rsinfo,getinfo,daconn,fn_now
if request.querystring(&quot;calendar&quot;) <> &quot;&quot; then
calendarname=request.querystring(&quot;calendar&quot;)
response.cookies(&quot;calendar&quot;)=request.querystring(&quot;calendar&quot;)
else
calendarname=request.cookies(&quot;calendar&quot;)
end if

'response.write request.cookies(&quot;calendar&quot;)
Session(&quot;submitted&quot;) = True
%>
<!-- #include file=&quot;db.asp&quot; -->
<%
set my_conn= daconn




Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), &quot;&quot;)
String = Replace(String, CHR(10) & CHR(10), &quot;</P><P>&quot;)
String = Replace(String, CHR(10), &quot;<BR>&quot;)
FormatStr = String
End Function

Dim dtToday,my_conn,dbpath,payroll,strsql,rs,rs2,rs3,strsql2,stryear,rsyearly,cnpath
dtToday = Date()

Dim dtCurViewMonth ' First day of the currently viewed month
Dim dtCurViewDay ' Current day of the currently viewed month
Dim frmDate,tmpMonth,tmpYear,tmpDate,mnth ' Date submitted by form

' if the GO button was used, build the date from the month and year

If InStr(1, Request.Form, &quot;subGO&quot;, 1) > 0 then
if Request.Form(&quot;CURDATE_month&quot;) = &quot;&quot; then
tmpMonth = month(now())
else
tmpMonth = Request.Form(&quot;CURDATE_month&quot;)
End If

if Request.Form(&quot;CURDATE_year&quot;) = &quot;&quot; then
tmpyear = year(now())
else
tmpyear = Request.Form(&quot;CURDATE_year&quot;)
End If

tmpDate = &quot;1 &quot; & tmpMonth & &quot; 2001&quot;

mnth = Month(tmpDate)
frmDate = DateSerial(tmpyear, mnth, 1)
Else

frmDate = Request.Form(&quot;CURDATE&quot;)

end if

if Request(&quot;view_date&quot;) <> &quot;&quot; then
frmDate= DateSerial(year(Request(&quot;view_date&quot;)), month(Request(&quot;view_date&quot;)), 1)
end if

%>
<% REM This section defines functions to be used later on. %>
<% REM This sets the Previous Sunday and the Current Month %>
<%

'--------------------------------------------------
Function DtPrevSunday(ByVal dt)
Do While WeekDay(dt) > vbSunday
dt = DateAdd(&quot;d&quot;, -1, dt)
Loop
DtPrevSunday = dt
End Function
'--------------------------------------------------
%>
<%REM Set current view month from posted CURDATE, or
' the current date as appropriate.

' if posted from the form
' if prev button was hit on the form
If InStr(1, Request.Form, &quot;subPrev&quot;, 1) > 0 Then
dtCurViewMonth = DateAdd(&quot;m&quot;, -1, frmDate)

' if next button was hit on the form
ElseIf InStr(1, Request.Form, &quot;subNext&quot;, 1) > 0 Then
dtCurViewMonth = DateAdd(&quot;m&quot;, 1, frmDate)
' elseif request.querystring(&quot;subprev&quot;)=1 then
' dtCurViewMonth = DateAdd(&quot;m&quot;, -1, frmDate)

' anyother time
Else
' date add in text box
If InStr(1, Request.Form, &quot;subGO&quot;, 1) > 0 then
dtCurViewMonth = frmDate
Else
if Request(&quot;view_date&quot;) <> &quot;&quot; then
dtCurviewMonth = frmDate
else
dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
End If
End If

End If

%>


<% REM --------BEGINNING OF DRAW CALENDAR SECTION-------- %>
<% REM This section executes the event query and draws a matching calendar. %>
<%
Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount

'get calendar info
'getinfo=&quot;select * from main where tablename='&quot; &calendarname &&quot;';&quot;
'set rsinfo=my_conn.execute(getinfo)

strSql = &quot;SELECT * FROM evantcalendar WHERE year(dte) = &quot; & year(dtCurViewMonth) &&quot; AND month(dte)= &quot; & month(dtCurViewMonth) & &quot; ORDER BY Day(dte)&quot;
'response.write strsql &&quot;<BR>&quot;
set rs = my_conn.Execute (StrSql)

intCount= 0
' populate array with days of month
do until rs.EOF or intCount = 31

dictDte(intCount, 2) = intCount + 1


if Day(rs(&quot;dte&quot;)) = intCount + 1 then

if dictDte(intCount, 1) <> &quot;&quot; then

dictDte(intCount, 1) = rs(&quot;text_field&quot;) & &quot;<br>&quot; & dictDte(intCount, 1)
else
dictDte(intCount, 1) = rs(&quot;text_field&quot;)
end if

rs.Movenext

else
intCount = intCount + 1

End If

loop
rs.close

dim contactrs,consql
dim priconrs,prisql
'consql=&quot;select * from contacts where email<>'&quot; &rsinfo(&quot;primary_contact&quot;) &&quot;' AND email in (select contact from calcontact where visible=yes AND calendar='&quot; &rsinfo(&quot;title&quot;) &&quot;');&quot;
'response.write con1sql
'set contactrs=my_conn.execute(consql)

'prisql=&quot;select * from contacts where email='&quot; &rsinfo(&quot;primary_contact&quot;) &&quot;';&quot;
'response.write prisql
'set priconrs=my_conn.execute(prisql)


%>
<html>
<head>
<!--#INCLUDE FILE=&quot;../header.asp&quot; -->
<title> - Web Calendar</title>
<style fprolloverstyle>A:hover {color: #00FF00; text-decoration: none}
</style>
</head>
<body text=&quot;#000000&quot; link=&quot;#FFFFFF&quot; vlink=&quot;#FFFFFF&quot; alink=&quot;#FFFFFF&quot;>

<table border=0 width=&quot;100%&quot;>
<tr>
<td width=&quot;99%&quot;><h1 align=&quot;center&quot;><font color=&quot;#003399&quot; size=&quot;4&quot;>Yeled
V'Yalda Event Calendar</font></h1>
</td>
</tr>
</table>
<table CELLPADDING=&quot;3&quot; CELLSPACING=&quot;0&quot; WIDTH=&quot;100%&quot; BORDER=&quot;2&quot; BGCOLOR=&quot;#000099&quot; bordercolordark=&quot;#1C644C&quot; bordercolor=&quot;#000099&quot; bordercolorlight=&quot;#FFFFFF&quot;>
<tr VALIGN=&quot;MIDDLE&quot; ALIGN=&quot;CENTER&quot;>
<form NAME=&quot;fmNextPrev&quot; ACTION=&quot;index.asp&quot; METHOD=&quot;POST&quot;><input type=&quot;hidden&quot; name=&quot;CURDATE&quot; value=&quot;<%=dtCurViewMonth%>&quot;>
<td WIDTH=&quot;30%&quot; ALIGN=&quot;RIGHT&quot;>

<input TYPE=&quot;image&quot; NAME=&quot;subPrev&quot; SRC=&quot;previousmonth.gif&quot; BORDER=&quot;0&quot; align=&quot;right&quot;></span>

</td>
<td WIDTH=&quot;40%&quot;><font FACE=&quot;Arial&quot; COLOR=&quot;white&quot;><b><%=MonthName(Month(dtCurViewMonth)) & &quot; &quot; & Year(dtCurViewMonth)%> &nbsp;
</td>
<td WIDTH=&quot;30%&quot; ALIGN=&quot;LEFT&quot; colspan=&quot;7&quot;> <input TYPE=&quot;image&quot; NAME=&quot;subNext&quot; SRC=&quot;nextmonth.gif&quot; BORDER=&quot;0&quot; HSPACE=&quot;0&quot; VSPACE=&quot;0&quot; align=&quot;absbottom&quot;>
</td>
</form>

</tr>
</table>
<table CELLPADDING=&quot;3&quot; CELLSPACING=&quot;0&quot; WIDTH=&quot;100%&quot; BORDER=&quot;2&quot; BGCOLOR=&quot;#0000FF&quot; bordercolordark=&quot;#008000&quot; bordercolor=&quot;#000099&quot; bordercolorlight=&quot;#FFFFFF&quot; style=&quot;border-collapse: collapse&quot;>
<tr VALIGN=&quot;TOP&quot; ALIGN=&quot;CENTER&quot; BGCOLOR=&quot;#000099&quot;>
<% For iDay = vbSunday To vbSaturday %>
<th WIDTH=&quot;14%&quot;><font FACE=&quot;Arial&quot; SIZE=&quot;-2&quot; COLOR=&quot;#FFFFFF&quot;><%=WeekDayName(iDay)%></font>&nbsp;</th>
<%Next %>
</tr>
<%
dtCurViewDay = DtPrevSunday(dtCurViewMonth)

For iWeek = 0 To 5
Response.Write &quot;<TR VALIGN=TOP>&quot; & vbCrLf

Dim sBGCOLOR
sBGCOLOR = &quot;#99ccff&quot;


For iDay = 0 To 6
sBGCOLOR = &quot;#003399&quot;
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then sBGCOLOR = &quot;#99ccff&quot;
else
sBGCOLOR = &quot;#003399&quot;

End If
Response.Write &quot;<span><a href=view_day.asp?&quot; & &quot;view_date=&quot; & day(dtCurViewday) & &quot;-&quot; & monthname(month(dtCurViewday)) & &quot;-&quot;&Year(dtCurViewMonth)&&quot;><TD HEIGHT=50 bgcolor='&quot; & sBGCOLOR & &quot;' style=&quot;&quot;cursor:hand&quot;&quot; >&quot;


If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then
sFontColor = &quot;#00FF00<i></i>&quot;

Else
sFontColor = &quot;#00FF00&quot;
End If

'---- Write day of month
Response.Write &quot;<FONT FACE=&quot;&quot;Arial&quot;&quot; SIZE=&quot;&quot;-2&quot;&quot; COLOR=&quot;&quot;&quot; & sFontColor & &quot;&quot;&quot;><B>&quot;
Response.Write &quot;<a name=&quot; &Day(dtCurViewDay) & &quot;><a href=view_day.asp?&quot; & &quot;view_date=&quot; & day(dtCurViewday) & &quot;-&quot; & monthname(month(dtCurViewday)) & &quot;-&quot;&Year(dtCurViewMonth)&&quot;>&quot; & Day(dtCurViewDay) & &quot;</B><br><font color='&quot; &sFontColor &&quot;'>&quot; & formatStr(dictDte(Day(dtCurViewDay)- 1, 1)) & &quot;</a>&quot;

End If

Response.Write &quot;&nbsp</TD></a></span>&quot; & vbCrLf
dtCurViewDay = DateAdd(&quot;d&quot;, 1, dtCurViewDay)
Next
Response.Write &quot;</TR>&quot; & vbCrLf
Next
%>
<%REM --------END OF DRAW CALENDAR SECTION--------

my_conn.Close
set my_conn = nothing
%></table>
<table width=&quot;100%&quot;><tr><td width=&quot;33%&quot;> </td><td width=&quot;33%&quot;>
<center> <p align=&quot;center&quot;><form NAME=&quot;fmNextPrev2&quot; ACTION=&quot;index.asp&quot; METHOD=&quot;POST&quot;>
<select name=&quot;CURDATE_month&quot; size=&quot;1&quot;>
<option value=&quot;<%=monthName(month(dtCurViewMonth))%>&quot; selected><%=monthName(month(dtCurViewMonth))%> </option>
<option value=&quot;January&quot;>January </option>
<option value=&quot;February&quot;>February </option>
<option value=&quot;March&quot;>March </option>
<option value=&quot;April&quot;>April </option>
<option value=&quot;May&quot;>May </option>
<option value=&quot;June&quot;>June </option>
<option value=&quot;July&quot;>July </option>
<option value=&quot;August&quot;>August </option>
<option value=&quot;September&quot;>September </option>
<option value=&quot;October&quot;>October </option>
<option value=&quot;November&quot;>November </option>
<option value=&quot;December&quot;>December </option>
</select> <input TYPE=&quot;text&quot; NAME=&quot;CURDATE_YEAR&quot; VALUE=&quot;<%=year(dtCurViewMonth)%>&quot; size=&quot;6&quot;>

<input type=&quot;submit&quot; value=&quot;Click Me&quot; name=&quot;subGO&quot;></form>&nbsp;</p></td><td width=&quot;33%&quot; valign=&quot;top&quot;>
<p align=&quot;right&quot;>
<font color=black>Yearly events are in </font><span style=&quot;background-color: #000099&quot;><font color=&quot;#FFFF00&quot;>&nbsp;
yellow&nbsp; </font></span></p>
</td></tr>
</table>

</body>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top