473,545 Members | 529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

objRS.Filter problem

I am trying to create an events calendar with a complete month view. I
want to be able to get all the events for a particular month, using only
one recordset on the page then be able to loop through each day of that
month and output the events for a particular day for each day without
having to open up 28 to 31 different recordsets.

The problem that I am having is with the objRS.Filter on line #12 of the
asp code below. I can not figure out how to write it so that it finds
events like "Event 4", in the *** SQL SERVER RESULTS ***, which is an
event that spans multiple days, so it should appear on the calendar on
the following days: 11, 12, 13, 14, 15. As the objRS.Filter is written
now the event will only appear on the 11th and the 15th. Another problem
I see with the way the filter is that events like "Event 7" will not
appear properly on the calendar. Event 7 starts on May 29th and ends on
June 3, so how do I tell the filter to ignore May 3 and just display
records for the 29th, 30th and 31st?

=============== ==========
Here is my SQL Statement:
=============== ==========
SELECT EventId, dtStartDate, dtEndDate, datepart(d, dtStartDate) as
nDayStart, datepart(d, dtEndDate) as nDayEnd, EventTitle
FROM Events
WHERE (dtStartDate BETWEEN '5/1/2005' AND '5/31/2005') or (dtEndDate
BETWEEN '5/1/2005' AND '5/31/2005')
ORDER BY datepart(d, dtStartDate), datepart(d, dtEndDate),
CAST(dtStartTim e as smalldatetime);
**** SQL SERVER RESULTS ****

EventId dtDate dtEndDate nDayStart
nDayEnd EventTitle
-------- ---------------------- --------------------- ----------
-------- -----------
134 2005-05-05 00:00:00 2005-05-05 00:00:00 5 5
Event 1
207 2005-05-07 00:00:00 2005-05-07 00:00:00 7 7
Event 2
163 2005-05-10 00:00:00 2005-05-10 00:00:00 10 10
Event 3
172 2005-05-11 00:00:00 2005-05-15 00:00:00 11 15
Event 4
185 2005-05-12 00:00:00 2005-05-12 00:00:00 12 12
Event 5
152 2005-05-25 00:00:00 2005-05-25 00:00:00 25 25
Event 6
120 2005-05-29 00:00:00 2005-06-03 00:00:00 29 3
Event 7

(7 row(s) affected)
=============== ==========
Here is my ASP Statement
that builds the month view
of the calendar:
=============== ==========
dtDate = Now()

1. set objRS = objConn.execute (strSQL)
2. do until (Month(dtDate) <> CInt(nMonth))
3. if Weekday(dtDate) = 1 or Weekday(dtDate) = 7 then
4. 'Sunday or Saturday so color them differently than the regular
weekdays
5. Response.Write "<td width='" & CellWidth & "' class='weekendd ays'
valign='top'>"
6. else 'weekday
7. Response.Write "<td width='" & CellWidth & "' class='days'
valign='top'>"
8. end if
9. Response.Write "<font class='daynumbe rs'><b>"& Day(dtDate) &
"</b></font><br>"
10.
11. if not objRS.EOF then
12. objRS.Filter = "(nDay = " & DatePart("d", dtDate) & ") OR
(nDayEnd = " & DatePart("d", dtDate) & ")"
13.
14. if not objRS.EOF then
15. do while not objRS.EOF
16. Response.Write "<a href='" & SiteURL &
"/events.asp?Even tId=" & objRS("EventId" ) & "&nDate=" &
server.urlencod e(month(dtDate) & "/" & day(dtDate) & "/" & year(dtDate))
& "' class='CalEvent Links'>" & revnewstr(objRS ("EventTitle ")) &
"</a><br><br>"
17. objRS.MoveNext
18. loop
19. else
20. response.write( "<img src='" & SiteURL & "/images/spacer.gif'
height='50' width='25' border=0>")
21. end if
22. objRS.Filter = ""
23. else
24. response.write( "<img src='" & SiteURL & "/images/spacer.gif'
height='50' width='25' border=0>")
25. end if
26.
27. Response.Write "</td>" & vbCR
28.
29. if WeekDay(dtDate) = 7 then
30. Response.Write "</tr>" & vbCrLf & vbCRLF & "<tr>"
31. end if
32. 'add one day for next time around in loop
33. dtDate = DateAdd("d", 1, dtDate)
34. dtFullDate = DateAdd("d", 1, dtFullDate)
35. loop
36. objRS.close
37. Set objRS = Nothing

Any input is greatly appreciate!

Thanks,

Ed

*** Sent via Developersdex http://www.developersdex.com ***
Jul 22 '05 #1
1 2384
Edward Burns wrote:
I am trying to create an events calendar with a complete month view. I
want to be able to get all the events for a particular month, using
only one recordset on the page then be able to loop through each day
of that month and output the events for a particular day for each day
without having to open up 28 to 31 different recordsets.


First of all, create and populate a Calendar table:

create table Calendar
(calDate datetime primary key clustered)
declare @i int
set @i = 1
while @i < 366
begin
insert into calendar values (dateadd(d,@i,' 20041231'))
set @i = @i + 1
end

You will find other uses for this table, believe me (such as adding a column
to indicate whether or not the day is a working day, or a column to indicate
the week_of_month number, in the case of a fiscal period calendar).

Then, generate the events for the month:

select caldate,datepar t(dw,caldate) DayOfWeek,
eventid,eventti tle
from events e right join calendar c
on c.caldate between e.dtStartdate and e.dtEndDate
where caldate between '20050501' and '20050531'
order by caldate, eventid

Looping through these results should be a little easier for you. I don't
really have time to analyze your code to figure out how you want the results
to look, so i can't get too specific here.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6457
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the report are based on the same View addressed in the Record Source of both as 'dbo.CLMain_vw'. The View resides in a SQL Server 2000 database. There are...
3
6597
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt...
2
5029
by: Salad | last post by:
I have a log file with a list of records. The log file can be unfiltered or filtered. I have a command button to call a data entry form from the log. At first I was only going to present the record the user selected. Then I thought, what the heck, give the user all of them but start out at the record the user is currently on. If I...
2
2478
by: Mike Sweetman | last post by:
I have a form Form1 which when the Advanced Filter/Sort is used creates a form(maybe) with a title 'Form1Filter1 : Filter'. When I apply the filter to Form1 it is applied, but the value of Form1.Filter is ''. How do I obtain the Advanced Filter/Sort criteria as a string ? I cannot reference the object 'Form1Filter1 : Filter' by using...
2
4013
by: Lenin Torres | last post by:
Hi everybody I have an Union Query that works fine. I used this query as the RecordSource for a Form. That Form is used as a subform in another form. Everything works fine, except for the "Filter by form" feature. When the user tries to use Filter by form a messagebox is displayed: "There are too many controls in this form to perform a...
3
2441
by: Brad | last post by:
I have a response filter which injects "standard" html into my pages. The filter works fine when the initial stream is small enough not to buffer...or....if I have a large unbuffered stream (i.e. I set buffer=false on a large page). Now the problem: If I turn on buffering on a large page, the page output (to the browser) is correct a few...
1
1954
by: new214 | last post by:
Hey all, got abit of a problem. Ive got a database where ive got 2 tables. I want to create a command which selects * from table 1 and if the same values are in table2 - it updates otherwise adds. Ive got a loop so i can run through the data records But i dont know how i check 1 objrs against another within an sql statement?? please look at...
6
4173
by: bammo | last post by:
MS Access 2003, Windows XP SP2, VBA I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in several combo boxes on the form. The filter is updated whenever the user changes his/her selection. My problem is when the user selects a filter...
2
4193
by: Matthew Wells | last post by:
Hi there. I am a programmer for a living, but this problem has my whole team stumped. I have a subform based on a query. I'm not using the "LinkMaster/ChildFields" properties ( I have my reasons ). The ssbform's query has a criteria for forms!masterform!Keyfield. This works fine on open. I have an options group with two options - True...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.