Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 Help Writing Loop for Events Calendar Recurrence
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Bookie
Average Member

USA
856 Posts

Posted - 10 July 2001 :  20:17:31  Show Profile  Visit Bookie's Homepage  Send Bookie an AOL message  Send Bookie a Yahoo! Message
Ok. I've got the idea and I know how it should work but I need help writing the code.

I'm adding two form fields to the form to submit events to a calendar... recur_num and recur_freq. Recur_num is the number of times you want to repeat the event. Recur_freq is the frequency you want to repeat it (daily-1, weekly-7, monthly-??, yearly-365).

For as many times as I want to repeat the event it will loop through and execute another sql string. Each time it executes the string, it will add 1, 7, or 365 days to the date. I've figured out how to add days to the start date but I just need some help with the loop.

-----------------------------------------------------------
If sUpdateMode = "edit" Then
sSQL = "UPDATE " & strTablePrefix & "EVENTS SET Start_Date = '" & DateToStr(Request.Form("START_DATE")) & "', End_Date = '" & DateToStr(enddate) & "', Event_Title = '" & chkstring(Request.Form("EVENT_TITLE"), "message") & "',PRIVATE = " & intPrivateEvent
sSQL = sSQL & ", Event_Details = '" & chkstring(Request.Form("Message"), "message") & "', date_added = '" & DateToStr(now()) & "' WHERE Event_ID=" & Request.Form("Event_ID")
my_Conn.Execute sSQL
Else
sSQL = "INSERT INTO " & strTablePrefix & "EVENTS (Start_Date, End_Date, Event_Title, Event_Details, Date_Added, Added_by, PRIVATE) Values ('" & DateToStr(Request.Form("START_DATE")) & "', '" & DateToStr(enddate) & "',' " & chkstring(Request.Form("EVENT_TITLE"), "message") & "', '" & chkstring(Request.Form("Message"), "message") & "', '" & DateToStr(now()) & "', " & memberid & "," & intPrivateEvent & ")"
' response.write(sSQL)
' response.write("<BR>"&DateToStr(cDate(Request.Form("start_date"))+7)) // This works!!
' my_Conn.Execute sSQL
'####################
if NOT Request.Form("recur_num") = "0" then
Dim recur_freq
recur_freq = Request.Form("recur_freq")
i=i+1
' start of loop (loop as many times as recur_num)
sSQL+i = "INSERT INTO " & strTablePrefix & "EVENTS (Start_Date, End_Date, Event_Title, Event_Details, Date_Added, Added_by, PRIVATE) Values ('" & DateToStr(cDate(Request.Form("START_DATE"))+recur_freq)) & "', '" & DateToStr(cDate(Request.Form("END_DATE"))+recur_freq) & "',' " & chkstring(Request.Form("EVENT_TITLE"), "message") & "', '" & chkstring(Request.Form("Message"), "message") & "', '" & DateToStr(now()) & "', " & memberid & "," & intPrivateEvent & ")"
my_Conn.Execute sSQL+i
loop
end if
'####################
End If
-----------------------------------------------------------

Help??

Bookie

"May the forces of evil become confused on the way to your home."
- George Carlin

Edited by - Bookie on 10 July 2001 20:20:50

Bookie
Average Member

USA
856 Posts

Posted - 10 July 2001 :  21:25:23  Show Profile  Visit Bookie's Homepage  Send Bookie an AOL message  Send Bookie a Yahoo! Message
I've figured out a basic addition to accomplish an event recurrance. However, I would not recommend this as a mod add-on until other people look over the code and make appropriate changes.

For example, for this to work effectively, a person would want to repeat a monthly event on the same date. Since I have this adding days to the date, I'm not able to add a month because a month may be 28, 30, or 31 days. Same with a leap year. If someone can figure this out, let me know. Perhaps there are other issues to consider that I don't know about.

Take a look at the code. There are two things you would need to add to the events_functions.asp page. You should be able to find the spots and add the code.

http://www.bookfamily.net/forum/event_recur.txt

Bookie

"May the forces of evil become confused on the way to your home."
- George Carlin
Go to Top of Page

bjlt
Senior Member

1144 Posts

Posted - 10 July 2001 :  22:20:49  Show Profile
I'm sure you can find a function for recuring date in month. Just search around in the asp resources. I'm looking for it now. will post here if i found any.


here's an example.
http://baltimores.inyourtown.com/event/eventsubmit.asp?m=27


Edited by - bjlt on 10 July 2001 22:34:32
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07