Record displaying twice

Im using asp and sql on a iis host . My whole site works fine except it dispays the same record twice on a report.asp page. It has the same ID and only shows up once in the
access database.
tmurray22Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VirusMinusCommented:
posting your code may help;

Also is it the last record in a loop?

If yes then adding the following may help ->

While NOT rs.EOF

 '... Display your info ...

 If Not rs.EOF then
   rs.Movenext
 End if

Wend
0
sprisonerCommented:
one more reason may be JOINs, if there are any in the query. so as VirusMinus says, little it of ur code can help us catch the bug.

Nash
0
Saqib KhanSenior DeveloperCommented:
Maybe you have Records Recorded Twice in Database?

Try Running your SQL statement with DISTINCT keyworks

Selecr DISTINCT COL1, COL2 From TableName
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

aprestoCommented:
i think he said it only in the db once but wouldnt hurt to check i suppose.  Make sure you have a field that is the primary key as this uniquely identifies a record.  I tihnk virusminus is right aswell, sounds like a loop.  Make sure if you have this line in your code:

rs.movefirst

It is after an IF but BEFORE a while
0
Melih SARICAOwnerCommented:
r u using a Join Statement ?.. if u r joining 2 tables. it can be twice in one of the Tables

Melih SARICa
0
peh803Commented:
If you're still unable to fix your problem given the posts above, please post your code.

Thanks,
peh803
0
tmurray22Author Commented:
There is only one record recorded in datbase. The records that display twice are actually referring to the same record. Here is a sample link that shows both having
the same unique ID.

http://pysdoorway/scm/scheduler/mc25/manage/event_view.asp?ID=90


Here is the code for the page that displays the entries.
Below that is the page with the SQL that qualifies the records to be displayed.



'Calendar.ASP

<!--#include file="../config.asp"-->

<% Dim C_MONTH, C_YEAR, C_FIRSTD, C_CRD, I, C_CRDATE, SEL_CATE, sUW, blTODAY
       With Request
            C_MONTH  = Trim(.Querystring("Month"))
            C_YEAR   = Trim(.Querystring("Year"))
            SEL_CATE = Trim(.QueryString("cate"))
       End With
             
       IF (Len(C_MONTH) = 0) OR (C_MONTH = "") OR (IsNull(C_MONTH)) then C_MONTH = Month(Date)
       IF (Len(C_YEAR)  = 0) OR (C_YEAR = "") OR (IsNull(C_YEAR)) then C_YEAR = Year(Date)
     IF IS_VALID_ID(C_MONTH) = False THEN C_MONTH = Month(Date)
     IF IS_VALID_ID(C_YEAR) = False THEN C_MONTH = Year(Date)
     IF NOT (SEL_CATE = "0" OR IS_VALID_ID(SEL_CATE) = True) THEN SEL_CATE = "0"
       C_FIRSTD = WeekDay(DateSerial(C_YEAR, C_MONTH, 1)) -1       
       C_CRD = 0       
     
      %>

      <!--#include file="inc_functions.asp"-->
      <!--#include file="../inc_api.asp"-->
      <!--#include file="inc_header.asp"-->
      
      <%
       Call OPEN_DB()
     sUW = Trim(RETURN_CAL_SET(False, "fldUW", Session("C_ID")))
     IF sUW = "1" THEN
        USE_WEEKNUM = True
     ELSE
        USE_WEEKNUM = False    
     END IF
     
        Call INC_C_DROPS()
       Call INC_C_HEADER(C_MONTH, C_YEAR)       
      
            FOR I = 1 TO LastDay(C_MONTH, C_YEAR)
                  C_CRD = C_CRD + 1
                  If (Trim(C_MONTH) = Trim(Month(Date))) AND (Trim(Day(Date)) = Trim(C_CRD)) Then
                blTODAY = True
            else
                blTODAY = False
            end if    
            C_CRDATE = ASDATE(C_MONTH, C_CRD, C_YEAR)            
            C_CRDATE = FormatDateTime(C_CRDATE,2)
           
                  %>
                  <tr>
                        <td bgcolor="#F7F7F7" width="70" valign="top"><% If blTODAY = True Then %><font color="black"><b><%=arrDAYNAMES(Weekday(C_CRDATE)-1)%></b></font><%Else%><%=arrDAYNAMES(Weekday(C_CRDATE)-1)%><%End If%></td>
                        <td align="center" bgcolor="#F7F7F7" width="25" valign="top"><% If blTODAY = True Then %><font color="black"><b><%=C_CRD%></b></font><%Else%><%=C_CRD%><%End If%></td>
                <%If USE_WEEKNUM = True Then%><td align="center" bgcolor="#F7F7F7" width="25" valign="top"><%=GET_WEEK_NUMBER(C_CRDATE)%></td><%End If%>
                        <td width="100%" valign="top">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
                          <td width="13"><a href="event_add.asp?qmode=1&m=<%= C_MONTH %>&d=<%= C_CRD %>&y=<%= C_YEAR %>"><img src="../images/ico_plus.gif" width="13" height="13" alt="Add New Reservation" border="0" /></a></td>
                          <td><%=CHECK_EVENTS(False, Session("C_ID"), C_CRDATE)%></td>
                    </tr></table>
                </td>
                  </tr>            
                  <%
            NEXT
      
            
       Call INC_C_FOOTER()
       MyConn.Close
       Set MyConn = Nothing      

%><!--#include file="inc_footer.asp"-->




'inc_functions.asp

<%
FUNCTION CHECK_EVENTS_ALLCALS(OPEN, ID, sDATE)
Dim E_TITLE, E_ID, SQL, E_COLOR, intWEEKDAY, blFOUND, strCATE_SQL, STIME, ETIME, strTIME, sQ, MID_SQL, C_NAME
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      blFOUND = False
      intWEEKDAY = Weekday(sDATE)
      IF (SEL_CATE = "") OR (IsNull(SEL_CATE)) OR (SEL_CATE = "0") THEN
            SEL_CATE = ""
      ELSE
            strCATE_SQL = " AND (mc_tbl_event.fldCATE_ID=" & SEL_CATE & ")"
      END IF
      '----------------------------------------'
    IF CALSIDS = "" OR IsNUll(CALSIDS) THEN ' SHOW ALL CALENDARS
        IF SHOWN = "1" THEN ' SHOW CALENDAR NAME
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            ELSE
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            END IF
        ELSE
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            ELSE            
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            END IF
        END IF            
      ELSE ' SHOW ONLY DESIRED CALENDARS
       
        MID_SQL = "AND ("
        FOR sQ = 0 TO Ubound(arrCALSIDS)
            IF Not ((Trim(arrCALSIDS(sQ)) = "") OR (IsNUll(arrCALSIDS(sQ)))) THEN                
                    MID_SQL = MID_SQL & "(mc_tbl_event.fldCAL_ID = " & Trim(arrCALSIDS(sQ)) & ") OR "                 
            END IF
        NEXT            
        MID_SQL = Mid(MID_SQL,1,Len(MID_SQL)-3)
            MID_SQL = MID_SQL & ") "
       
        IF SHOWN = "1" THEN ' SHOW CALENDAR NAME
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME  FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"    
            ELSE
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME  FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"            
            END IF
        ELSE
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"            
            ELSE
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            END IF
        END IF            
    END IF
   
'    response.write SHOWN & "<br>" & SQL
'    response.End
   
          Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         E_TITLE = trim(RS("E_TITLE"))
                        E_ID    = trim(RS("E_ID"))
                        E_COLOR = trim(RS("E_COLOR"))
                        STIME = trim(RS("fldSTIME"))
                        ETIME = trim(RS("fldETIME"))
                IF SHOWN = "1" THEN C_NAME = trim(RS("C_NAME"))                
                        '--------------------------'
                        IF NOT ((STIME = "") OR (ETIME = "")) THEN
                              strTIME = "[" & STIME & "-" & ETIME & "] "
                        ELSE
                              IF ((Trim(ETIME) = "") OR (IsNull(ETIME))) AND ((Trim(STIME) = "") OR (IsNull(STIME))) THEN
                                    strTIME = ""
                              ELSE
                                    IF NOT ((Trim(STIME)="") OR (IsNull(STIME))) THEN
                                          strTIME = "[" & STIME & "] "
                                    ELSE
                                          strTIME = ""      
                                    END IF                                    
                              END IF      
                        END IF      
                        '--------------------------'
                        blFOUND = True
                IDS = IDS & E_ID & ","
                        %>
                        <br /><% IF SHOWN = "1" THEN %><i><%= C_NAME %></i><br /><% End If %><a title="<%= arrCOMMON(1) %>" style="color:<%=E_COLOR%>" href="event_view.asp?EID=<%=E_ID%>&ID=<%=ID%>&cTYPE=<%=cTYPE%>"><%=strTIME%><%=PROCESS_SIGNS(E_TITLE, ID, False)%></a><br />
                        <%
                      RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing
            
            IF cTYPE = "1" THEN
                  IF blFOUND = False Then Response.Write "&nbsp;<br /><br /><br /><br />"            
            ELSE
                  IF blFOUND = False Then Response.Write "&nbsp;"
            END IF      
      '----------------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION


'// PURPOSE:
'          Get calendar name and description
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
'   NOTES:
'          varailable NAME and DES is a declared in calendar.asp
PRIVATE FUNCTION GET_NAME(ID, OPEN)
Dim SQL, RS, strCATE, EXPIN, SINCE
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
            SQL = "SELECT fldNAME, fldDES, fldACTIVE, fldEXP_IN, fldSINCE, fldPUBLIC FROM mc_tbl_calendar WHERE ID = " & ID
            Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1 '// adLockReadOnly
            RS.CursorType = 0  '// adOpenForwardOnly
            RS.Open SQL, MyConn      
                   IF NOT RS.EOF THEN
                         NAME = trim(RS("fldNAME"))
                        DES = trim(RS("fldDES"))
                        ACTIVE = trim(RS("fldACTIVE"))
                EXPIN  = trim(RS("fldEXP_IN"))
                SINCE  = trim(RS("fldSINCE"))
                cPUBLIC = trim(RS("fldPUBLIC"))
                EXPIN = FormatNumber(((CDate(SINCE)+Cdbl(EXPIN)) - Date),0)                
                IF EXPIN =< 0 THEN
                    MESSAGE = MESSAGE & "<li />" & arrERROR(0)
                END IF
                   END IF
            RS.Close
            Set RS = Nothing      
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION

'// PURPOSE:
'          Assemble category dropdown menu
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
PRIVATE FUNCTION GET_CATE_NAMES(ID, OPEN)
Dim SQL, RS, strCATE
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      '-----------------------------------'
            SQL = "SELECT ID, fldNAME, fldCOLOR FROM mc_tbl_cate WHERE (fldACTIVE = 1) AND (fldCAL_ID=" & ID & ") ORDER BY fldNAME ASC"
            Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         If SEL_CATE = trim(RS("ID")) Then                         
                              strCATE = strCATE & "<option style=" & chr(34) & "background-color:" & trim(RS("fldCOLOR")) & Chr(34) & " selected value=" & chr(34) & trim(RS("ID")) & chr(34) & ">" & trim(RS("fldNAME")) & Vbcrlf
                        Else
                              strCATE = strCATE & "<option style=" & chr(34) & "background-color:" & trim(RS("fldCOLOR")) & Chr(34) & " value=" & chr(34) & trim(RS("ID")) & chr(34) & ">" & trim(RS("fldNAME")) & Vbcrlf
                        End If                            
                        RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing            
      '-----------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
      '-----------------------------------'
      IF strCATE = "" THEN strCATE = "<option value=" & chr(34) & "0" & chr(34) & ">N/A" & Vbcrlf
      GET_CATE_NAMES = strCATE
END FUNCTION







'// PURPOSE:
'          Check for events at given date
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
'          sDATE - work with events of passed date
FUNCTION CHECK_EVENTS_SMALL(OPEN, ID, sDATE)
Dim SQL, intWEEKDAY, blFOUND, TOTAL
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      blFOUND = False
      intWEEKDAY = Weekday(sDATE)
        IF DB_TO_USE = 1 THEN ' MS Access
                SQL = "SELECT COUNT(mc_tbl_event.ID) AS TOTAL FROM mc_tbl_event WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _            
              "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)"
        ELSE
                SQL = "SELECT COUNT(mc_tbl_event.ID) AS TOTAL FROM mc_tbl_event WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _            
              "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)"        
        END IF    
            Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         TOTAL = RS("TOTAL")
                        blFOUND = True
                        IF Cint(TOTAL) > 0 THEN %>
                              <a href="small_view.asp?ID=<%=ID%>&cd=<%=sDATE%>"><b><%=TOTAL%></b></a><br />
                    <%ELSE%>
                                &nbsp;
                    <%END IF                        
                      RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing
            IF blFOUND = False Then Response.Write "&nbsp;"            
      '----------------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION

'// PURPOSE:
'          Check for events at given date
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
'          sDATE - work with events of passed date
FUNCTION CHECK_EVENTS(OPEN, ID, sDATE)
Dim E_TITLE, E_ID, SQL, E_COLOR, intWEEKDAY, blFOUND, strCATE_SQL, STIME, ETIME, strTIME
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      blFOUND = False
      intWEEKDAY = Weekday(sDATE)
      IF (SEL_CATE = "") OR (IsNull(SEL_CATE)) OR (SEL_CATE = "0") THEN
            SEL_CATE = ""
      ELSE
            strCATE_SQL = " AND (mc_tbl_event.fldCATE_ID=" & SEL_CATE & ")"
      END IF
          IF DB_TO_USE = 1 THEN ' MS Access
                SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
              "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"    
        ELSE
                SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
              "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"            
        END IF    
          Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         E_TITLE = trim(RS("E_TITLE"))
                        E_ID    = trim(RS("E_ID"))
                        E_COLOR = trim(RS("E_COLOR"))
                        STIME = trim(RS("fldSTIME"))
                        ETIME = trim(RS("fldETIME"))
                        '--------------------------'
                        IF NOT ((STIME = "") OR (ETIME = "")) THEN
                              strTIME = "[" & STIME & "-" & ETIME & "] "
                        ELSE
                              IF ((Trim(ETIME) = "") OR (IsNull(ETIME))) AND ((Trim(STIME) = "") OR (IsNull(STIME))) THEN
                                    strTIME = ""
                              ELSE
                                    IF NOT ((Trim(STIME)="") OR (IsNull(STIME))) THEN
                                          strTIME = "[" & STIME & "] "
                                    ELSE
                                          strTIME = ""      
                                    END IF                                    
                              END IF      
                        END IF      
                        '--------------------------'
                        blFOUND = True
                IDS = IDS & E_ID & ","
                        %>
                        <a title="<%= arrCOMMON(1) %>" style="color:<%=E_COLOR%>" href="event_view.asp?EID=<%=E_ID%>&ID=<%=ID%>&cTYPE=<%=cTYPE%>"><%=strTIME%><%=PROCESS_SIGNS(E_TITLE, ID, False)%></a><br />
                        <%
                      RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing
            
            IF cTYPE = "1" THEN
                  IF blFOUND = False Then Response.Write "&nbsp;<br /><br /><br /><br />"            
            ELSE
                  IF blFOUND = False Then Response.Write "&nbsp;"
            END IF      
      '----------------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION

'// PURPOSE:
'          Draw begining of the calendar, with navigation
PRIVATE SUB INC_C_HEADER_SMALL(C_MONTH,C_YEAR)   %>
      <table border="1" cellspacing="0" cellpadding="2" width="200" align="center" bordercolor="#dadada">
        <tr bgcolor="WhiteSmoke">
            <td colspan="7" background="images/bg1.gif">
                  <% Call INSERT_NAVIG_SMALL %>
            </td>
        </tr>      <%
END SUB
'// PURPOSE:
'          Draw begining of the calendar, with navigation
PRIVATE SUB INC_C_HEADER(C_MONTH,C_YEAR)   %>
      <table border="1" cellspacing="0" cellpadding="2" width="550" align="center" bordercolor="#e5e5e5">
        <tr bgcolor="WhiteSmoke">
            <td colspan="7">
                  <% Call INSERT_NAVIG %>
            </td>
        </tr>      <%
END SUB

'// PURPOSE:
'          Insert top row, containing month name and navig arrows.
PRIVATE SUB INSERT_NAVIG() %>
      <table border="0" cellspacing="1" cellpadding="1" width="100%" class="tblARROWNAVIG"><tr>
      <td align="left" width="15" background="images/bg1.gif">
            <%
        IF ID = "" OR IsnuLL(ID) THEN
                Response.write "<a href = 'all_calendars.asp?"
                IF C_MONTH - 1 = 0 THEN
                      response.write "month=12&year=" & C_YEAR -1 & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH - 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_left.gif' width='15' height='13' border='0'></a>"
        ELSE
                Response.write "<a href = 'calendar.asp?"
                IF C_MONTH - 1 = 0 THEN
                      response.write "month=12&year=" & C_YEAR -1 & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH - 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_left.gif' width='15' height='13' border='0'></a>"
        END IF    
            %>
      </td><td background="images/bg1.gif" align="center"><%=arrMONTHNAME(C_MONTH-1) & " " & C_YEAR%></td>
      <td align="right" width="15" background="images/bg1.gif">
            <%
        IF ID = "" OR IsnuLL(ID) THEN
                Response.write "<a href = 'all_calendars.asp?"
                IF C_MONTH + 1 = 13 THEN
                      response.write "month=1&year=" & C_YEAR + 1 & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH + 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_right.gif' width='15' height='13' border='0'></a>"
        ELSE
                Response.write "<a href = 'calendar.asp?"
                IF C_MONTH + 1 = 13 THEN
                      response.write "month=1&year=" & C_YEAR + 1 & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH + 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_right.gif' width='15' height='13' border='0'></a>"        
        END IF
            %>      
      </td></tr></table> <%
END SUB

'// PURPOSE:
'          Insert top row, containing month name and navig arrows.
PRIVATE SUB INSERT_NAVIG_SMALL() %>
      <table border="0" cellspacing="1" cellpadding="1" width="100%" class="tblARROWNAVIG"><tr>
      <td align="left" width="15" background="images/bg1.gif">
            <%
            Response.write "<a href = 'small.asp?"
            IF C_MONTH - 1 = 0 THEN
                  response.write "month=12&year=" & C_YEAR -1 & "&ID=" & ID
            ELSE
                  response.write "month=" & C_MONTH - 1 & "&year=" & C_YEAR & "&ID=" & ID
            END IF
            Response.write "'><img src='images/arrow_left.gif' width='15' height='13' border='0'></a>"
            %>            
      </td><td align="center" background="images/bg1.gif"><%=arrMONTHNAME(C_MONTH-1) & " " & C_YEAR%></td>
      <td align="right" width="15" background="images/bg1.gif">
            <%
            Response.write "<a href = 'small.asp?"
            IF C_MONTH + 1 = 13 THEN
                  response.write "month=1&year=" & C_YEAR + 1 & "&ID=" & ID
            ELSE
                  response.write "month=" & C_MONTH + 1 & "&year=" & C_YEAR & "&ID=" & ID
            END IF
            Response.write "'><img src='images/arrow_right.gif' width='15' height='13' border='0'></a>"
            %>      
      </td></tr></table> <%
END SUB

'// PURPOSE:
'          Draw last row of calendar table, include naviagation
PRIVATE SUB INC_C_FOOTER()
            %>
            <tr bgcolor="WhiteSmoke">
             <td colspan="7">
                  <% Call INSERT_NAVIG %>
             </td>
            </tr></table>
        <%
END SUB

'// PURPOSE:
'          Draw last row of calendar table, include naviagation
PRIVATE SUB INC_C_FOOTER_SMALL()
            %>
            <tr bgcolor="WhiteSmoke">
             <td colspan="7">
                  <% Call INSERT_NAVIG_SMALL %>
             </td>
            </tr></table>
        <%
END SUB

'// PURPOSE:
'          Draw begining of the calendar, with navigation
PRIVATE SUB INC_C_HEADER_FULL(C_MONTH,C_YEAR)   %>
      <table border="1" cellspacing="0" cellpadding="2" width="550" align="center" bordercolor="#dadada">
        <tr bgcolor="WhiteSmoke">
            <td colspan="<%If USE_WEEKNUM = True Then%>4<%Else%>3<%End If%>">
                  <% Call INSERT_NAVIG %>
            </td>
        </tr>      <%
END SUB

'// PURPOSE:
'          Draw last row of calendar table, include naviagation
PRIVATE SUB INC_C_FOOTER_FULL()
            %>
      <tr bgcolor="WhiteSmoke">
       <td colspan="<%If USE_WEEKNUM = True Then%>4<%Else%>3<%End If%>">
            <% Call INSERT_NAVIG %>
       </td>
      </tr></table>
      <br />
        <%
END SUB
%>
0
peh803Commented:
Holy cow, that's a lotta code!  Are you sure ALL that code is applicable to the part that's showing the same record twice?  Also, I was unable to view your link referenced above for the example...

peh803
0
SquareHeadCommented:
Maybe you've tried this?

Try a response.write on your SQL statement, post it here.

Have you tried executing the SQL statement in SQL View? Does it return one record? If so, the problem is probably in your ASP code. If the SQL returns more than one record, then it's probably the SQL...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SquareHeadCommented:
In other words, display your entire SQL statement on the screen, then cut & paste into Access' SQL View and execute... See what you get...
0
tmurray22Author Commented:
That did it I posted the different queries until i finally found the one generating the same record twice. It wasreferencing the ID twice before the end of the query.


Thanks
for all your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.