help with the loop pls

P

ptrlks

Hi again,



the problem is in this code:
Code:
ElseIf Right(rsBokad("aktivitet"),
3) = "Cup" Then

dStartDate = Cdate(rsBokad("startDatum"))

dEndDate = Cdate(rsBokad("endDatum"))

For dTempDate = dStartDate to dEndDate

If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then

Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")

Response.Write ", i " & rsBokad("lokal")

End If

Next

ElseIf Right(rsBokad("aktivitet"), 3) = "Cam" Then

dStartDate = Cdate(rsBokad("startDatum"))

dEndDate = Cdate(rsBokad("endDatum"))

For dTempDate = dStartDate to dEndDate

If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then

Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")

Response.Write ", i " & rsBokad("lokal")

End If

Next

This is what I want to do:

If Right(rsBokad("aktivitet"), 3) = "Cam" Then
if dTempDate = dStartDate
If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then Write
set dTempDate = dStartDate + 1
If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then Write
set dTempDate = dStartDate + 2
If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then Write
Repeat this until dTempDate = dendDate


Being from Sweden I apologize for my English
Thanks in advance
As a NOOB any help we'll be appreciated
/Peter
 
B

Bob Barrows [MVP]

ptrlks said:
Hi again,



the problem is in this code:

What are the symptoms of your problem? Don't make us attempt to run your
code to discover your symptoms.


Bob Barrows
 
B

Bob Barrows [MVP]

ptr said:
the symptom is: that it stops the output where
dTempDate = dStartDate
Ah! That helps. I have to go to work now, but I will look at this later and
reply if nobody else has jumped in by then.

Bob Barrows
 
P

ptrlks

Bob Barrows said:
Ah! That helps. I have to go to work now, but I will look at this later and
reply if nobody else has jumped in by then.

Bob Barrows

Hi, the pages are in swedish, but i hope the still helps you
understand my problems:
this page http://www45.brinkster.com/ovaasp/list.asp uses
<%
Session.LCID = 1053
Set minCon = Server.CreateObject("ADODB.Connection")
set rsBokad = Server.CreateObject("ADODB.Recordset")
minCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("\ovaasp\db\upptaget.mdb")
strSQL =" SELECT * FROM upptaget ORDER by ID ASC"
rsBokad.Open strSQL, minCon, 3, 3

Do While Not rsBokad.EOF
If Left(rsBokad("aktivitet"), 3) = "Trä" Then
Response.Write "<BR>" & rsBokad("startDatum") & " " &
rsBokad("aktivitet") & " "
Response.Write FormatDateTime(rsBokad("startTid"), 4) & " - "
Response.Write FormatDateTime(rsBokad("endTid"),4) & ", " &
rsBokad("lokal") & "<BR>"
ElseIf Left(rsBokad("aktivitet"), 2) = "Ma" Then
Response.Write "<P>" & rsBokad("startDatum") & " " &
rsBokad("aktivitet") & " mot "
Response.Write rsBokad("Mot") & " i " & rsBokad("lokal") & ", kl "
Response.Write FormatDateTime(rsBokad("startTid"), 4) & "<P>"
ElseIf Right(rsBokad("aktivitet"), 3) = "Cup" Then
dStartDate = Cdate(rsBokad("startDatum"))
dEndDate = Cdate(rsBokad("endDatum"))
For dTempDate = dStartDate to dEndDate
Response.Write "<P>" & dTempDate & " " & rsBokad("aktivitet") & " i
"
Response.Write rsBokad("lokal") & "<BR>"
Next
ElseIf Right(rsBokad("aktivitet"), 3) = "Cam" Then
dStartDate = Cdate(rsBokad("startDatum"))
dEndDate = Cdate(rsBokad("endDatum"))
For dTempDate = dStartDate to dEndDate
Response.Write "<P>" & dTempDate & " " & rsBokad("aktivitet") & " i
"
Response.Write rsBokad("lokal") & "<BR>"
Next
Else
Response.Write rsBokad("startDatum") & " " & rsBokad("aktivitet")
& " i "
Response.Write rsBokad("lokal") & "<BR>"

End if
rsBokad.MoveNext
Loop

rsBokad.Close
Set rsBokad = Nothing
minCon.Close
Set minCon = Nothing
%>
to list contents of a database. As you see occures "Ekens Cup, Solna"
5 times (3 - 7th jun)
Now please
1. visit http://www45.brinkster.com/ovaasp/skrivbordskalender115.asp
2. check "Nästa Månad"
3. press the button "Framåt" and you cames to jun-05
As you see, occurs "Ekens Cup, Solna" only on 3rd of jun and not on 4,
5, 6 and 7th why??
the code for http://www45.brinkster.com/ovaasp/skrivbordskalender115.asp
<%
Response.Write "<CENTER><FONT SIZE =""4""><B>" &
FirstVersal(MonthName(manad)) & ", " & ar & "</B></FONT></CENTER>"
Response.Write "<CENTER><TABLE CLASS=""table"" CELLSPACING=""0""
CELLPADDING=""1"">"
For iDag = 1 to DatePart("d", DateSerial(ar, manad+1, 0))
aDagar(iDag) = WeekDayName(DatePart("w",ar & "-" & manad & "-" &
iDag))
iWeekDay = DatePart("w",ar & "-" & manad & "-" & iDag)
Response.Write "<TR><TD CLASS=""tdleft"" ALIGN=""CENTER""
VALIGN=""BOTTOM""><CENTER><B><FONT SIZE=""5"">"
Response.Write iDag
Response.Write "</FONT></B></CENTER></TD><TD CLASS=""tdnamn""
VALIGN=""BOTTOM"">" & FirstVersal(aDagar(iDag)) & "</TD>"
Set minCon = Server.CreateObject("ADODB.Connection")
set rsBokad = Server.CreateObject("ADODB.Recordset")
minCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("\ovaasp\db\upptaget.mdb")
strSQL = "SELECT * FROM upptaget WHERE month(startDatum) = " & manad &
" AND day(startDatum) = " & iDag & " ORDER by ID ASC"
rsBokad.Open strSQL, minCon, 3, 3
Do While Not rsBokad.EOF
If Left(rsBokad("aktivitet"), 3) = "Trä" then
Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
Response.Write ", kl " & FormatDateTime(rsBokad("startTid"), 4) & "
- "
Response.Write FormatDateTime(rsBokad("endTid"), 4) & " , " &
rsBokad("lokal")
ElseIf Left(rsBokad("aktivitet"), 2) = "Ma" Then
Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
Response.Write " mot " & rsBokad("Mot")
Response.Write " i " & rsBokad("lokal") & ", kl "
Response.Write FormatDateTime(rsBokad("startTid"), 4)
ElseIf Right(rsBokad("aktivitet"), 3) = "Cup" Then
dStartDate = Cdate(rsBokad("startDatum"))
dEndDate = Cdate(rsBokad("endDatum"))
For dTempDate = dStartDate to dEndDate
If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then
Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
Response.Write ", i " & rsBokad("lokal")
End If
Next
ElseIf Right(rsBokad("aktivitet"), 3) = "Cam" Then
dStartDate = Cdate(rsBokad("startDatum"))
dEndDate = Cdate(rsBokad("endDatum"))
For dTempDate = dStartDate to dEndDate
If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then
Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
Response.Write ", i " & rsBokad("lokal")
End If
Next
Else
Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
Response.Write ", i " & rsBokad("lokal")

End if
rsBokad.MoveNext
Loop

rsBokad.Close
Set rsBokad = Nothing
minCon.Close
Set minCon = Nothing
%>So my problem/Q is:
Whu only on the 3rd and not on
4th
5th
6th
7th?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top