Hi,<BR><BR>I'm working on a database file, trying to pull information through a query and can't seem to figure out what's wrong.<BR><BR>A screenshot of the error is at http://www.grc-sports.com/error.jpg<BR><BR>The code I am working on is:<BR><BR>Microsoft VBScript runtime error '800a01a8' <BR><BR>Object required: '' <BR><BR>/pool/standings1920a-test.asp, line 257 <BR><BR><BR>CODE:<BR><BR><BR><% 'Open the database.<BR><BR> call OpenDB()<BR><BR> 'Tie breaker constant.<BR><BR> const TIE_BREAKER_MIN_WEEK = 120<BR><BR> 'Turn on tie breakers if the minimum week has been reached.<BR><BR> tieBreakersOn = false<BR> if CurrentWeek() >= TIE_BREAKER_MIN_WEEK then<BR> tieBreakersOn = true<BR> end if<BR><BR><BR> 'Set up conference and division names.<BR><BR> conferences = Array("NFL", "NFL")<BR> divisions = Array("Teams", "Teams")<BR><BR> 'Get list of teams and data ordered by conference and name.<BR><BR> dim teams<BR> n = NumberOfTeams()<BR> redim teams(n - 1)<BR><BR> i = 0<BR> sql = "select * from Teams1920 Where League = 'NFL' and Season = '1920' order by Conference, City, Name"<BR> set rs = DbConn.Execute(sql)<BR> if not (rs.BOF and rs.EOF) then<BR> do while not rs.EOF<BR> set teams(i) = new TeamObj<BR> teams(i).setData(rs.Fields("TeamID").Value)<BR> i = i + 1<BR> rs.MoveNext<BR> loop<BR> end if<BR><BR> %><BR><BR> <div align="center"><BR><BR><table cellpadding="0" cellspacing="0" class="main" width="90%"><BR><% <BR> alt = false<BR> for i = 0 to UBound(teams)<BR><BR><BR> alt = false %><BR><BR></tr><BR><BR><tr align="right"><BR><BR><tr align="right" class="alt"><BR><BR> <td bgcolor=#CCCCCC align="left" width="150"><font color="#D2D5F2"><BR><BR> <a href="team1920a.asp?id=<% = teams(i).id %>"><font color="#003366"><% = "<strong>" & teams(i).name & "</strong>" %></font></a><font <BR><BR>color="#000080"></font></td><BR> <td bgcolor=#CCCCCC><p align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = teams(i).totalWins %></font></td><BR> <td bgcolor=#CCCCCC><p align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = teams(i).totalLosses %></font></td><BR> <td bgcolor=#CCCCCC><p align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = teams(i).totalTies %></font></td><BR> <td bgcolor=#CCCCCC><p align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = FormatPercent(teams(i).totalPct) %></font></td><BR> <td bgcolor=#CCCCCC align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = teams(i).pointsFor %></font></td><BR> <td bgcolor=#CCCCCC align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = teams(i).PointsAgainst %></font></td><BR> <td bgcolor=#CCCCCC align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = FormatRecord(teams(i).homeWins, teams(i).homeLosses, <BR><BR>teams(i).homeTies) %></font></td><BR> <td bgcolor=#CCCCCC align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = FormatRecord(teams(i).roadWins, teams(i).roadLosses, <BR><BR>teams(i).roadTies) %></font></td><BR> <td bgcolor=#CCCCCC align="center"><font color="#000000" face="Tahoma" style="font-size: 8pt"><% = teams(i).streak %></font></td><BR></tr><BR><% next %><BR></table><BR><BR> </div><BR><BR><BR><BR><BR><BR><BR><% '******************************************** *******************************<BR> '* Local functions and subroutines. *<BR> '******************************************** *******************************<BR><BR><BR><BR> <BR><BR> '******************************************** *******************************<BR> '* Helper functions and subroutines. *<BR> '******************************************** *******************************<BR><BR> '---------------------------------------------------------------------------<BR> ' NumberOfTeams(): Returns the total number of teams in the database.<BR> '---------------------------------------------------------------------------<BR><BR> function NumberOfTeams()<BR><BR> dim sql, rs<BR><BR> NumberOfTeams = 0<BR> sql = "select count(TeamID) as total from Teams1920"<BR> set rs = DbConn.Execute(sql)<BR> if not (rs.BOF and rs.EOF) then<BR> NumberOfTeams = rs.Fields("total").Value<BR> end if<BR><BR> end function<BR><BR><BR><BR> '---------------------------------------------------------------------------<BR> ' SortByName(first, last): Sorts the global list of teams within the given<BR> ' range based the team name. Used if tie breakers are not employed or when<BR> ' a winner cannot be determined.<BR> '---------------------------------------------------------------------------<BR><BR> sub SortByName(first, last)<BR><BR> dim i, j, tmp<BR><BR> if last <= first then<BR> exit sub<BR> end if<BR><BR> for i = first to last - 1<BR> for j = i + 1 to last<BR> if teams(j).name < teams(i).name then<BR> set tmp = teams(i)<BR> set teams(i) = teams(j)<BR> set teams(j) = tmp<BR> end if<BR> next<BR> next<BR><BR> end sub<BR><BR> '---------------------------------------------------------------------------<BR> ' CalcPct(w, l, t): Calculates a winning percentage given a number of wins,<BR> ' losses and ties.<BR> '---------------------------------------------------------------------------<BR><BR> function CalcPct(w, l, t)<BR><BR> dim n<BR><BR> CalcPct = 0<BR> n = w + l + t<BR> if n > 0 then<BR> CalcPct = (w + t / 2) / n<BR> end if<BR><BR> end function<BR><BR> '---------------------------------------------------------------------------<BR> ' CountMatches(list, x): Returns the number of occurences of value 'x' in<BR> ' array 'list'. Used for head-to-head and common games tie breakers.<BR> '---------------------------------------------------------------------------<BR><BR> function CountMatches(list, x)<BR><BR> dim i<BR><BR> CountMatches = 0<BR> for i = 0 to UBound(list)<BR> if list(i) = x then<BR> CountMatches = CountMatches + 1<BR> end if<BR> next<BR><BR> end function<BR><BR> '---------------------------------------------------------------------------<BR> ' GetStrengthOfVictory(i): Returns the combined winning percentage of all<BR> ' teams beaten by the given team.<BR> '---------------------------------------------------------------------------<BR><BR> function GetStrengthOfVictory(i)<BR><BR> dim j, k<BR> dim w, l, t<BR><BR> GetStrengthOfVictory = 0<BR><BR> w = 0<BR> l = 0<BR> t = 0<BR><BR> 'Check only teams that have been beaten.<BR><BR> for j = 0 to UBound(teams(i).oppWonAgainst)<BR><BR> 'Get the opponent.<BR><BR> id = teams(i).oppWonAgainst(j)<BR> k = GetTeamIndex(id)<BR><BR> 'Add the opponent's record to the totals. Note that an opponent may be<BR> 'added more than once.<BR><BR> w = w + teams(k).totalWins<BR> l = l + teams(k).totalLosses<BR> t = t + teams(k).totalTies<BR> next<BR><BR> GetStrengthOfVictory = CalcPct(w, l, t)<BR><BR> end function<BR><BR> '---------------------------------------------------------------------------<BR> ' GetStrengthOfSchedule(i): Returns the combined winning percentage of all<BR> ' the given team's opponents.<BR> '---------------------------------------------------------------------------<BR><BR> function GetStrengthOfSchedule(i)<BR><BR> dim j, k<BR> dim w, l, t<BR> dim found<BR><BR> GetStrengthOfSchedule = 0<BR><BR> w = 0<BR> l = 0<BR> t = 0<BR><BR> 'Check all teams played.<BR><BR> for j = 0 to UBound(teams(i).allOpponents)<BR><BR> 'Get the opponent.<BR><BR> id = teams(i).allOpponents(j)<BR> k = GetTeamIndex(id)<BR><BR> 'Add the opponent's record to the totals. Note that an opponent may be<BR> 'added more than once.<BR><BR> w = w + teams(k).totalWins<BR> l = l + teams(k).totalLosses<BR> t = t + teams(k).totalTies<BR> next<BR><BR> GetStrengthOfSchedule = CalcPct(w, l, t)<BR><BR> end function<BR><BR> '---------------------------------------------------------------------------<BR> ' GetCombinedPointsRank(i, ownConf): Returns the combined ranking in points<BR> ' scored and points allowed by the given team. That is, the team's rank<BR> ' among other teams in PF plus it's rank in PA. If 'ownConf' is true, only<BR> ' teams in the same conference are considered.<BR> '---------------------------------------------------------------------------<BR><BR> function GetCombinedPointsRank(i, ownConf)<BR><BR> dim conf<BR> dim pf, pa<BR> dim j<BR> dim pfRank, paRank<BR><BR> GetCombinedPointsRank = -1<BR><BR> 'Get the team's conference.<BR> conf = teams(i).conference<BR><BR> 'Assume this team is the best in each category.<BR><BR> pfRank = 1 : paRank = 1<BR><BR> 'Compare this team's PF and PA totals to each of the other teams. Whenever<BR> 'another team has a better point total, bump this team's rank down by one.<BR><BR> for j = 0 to UBound(teams)<BR> if i <> j and (not ownConf or teams(j).conference = conf) then<BR> if teams(j).pointsFor > teams(i).pointsFor then<BR> pfRank = pfRank + 1<BR> end if<BR> if teams(j).pointsAgainst < teams(i).pointsAgainst then<BR> paRank = paRank + 1<BR> end if<BR> end if<BR> next<BR><BR> GetCombinedPointsRank = pfRank + paRank<BR><BR> end function<BR><BR><BR><BR><BR><BR> '---------------------------------------------------------------------------<BR> ' AddFootnote(s): Adds the given string to the tie breaker footnotes array.<BR> '---------------------------------------------------------------------------<BR><BR> sub AddFootnote(s)<BR><BR> dim n<BR><BR> n = UBound(footnotes)<BR> redim preserve footnotes(n + 1)<BR> footnotes(n + 1) = s<BR><BR> end sub<BR><BR> '******************************************** *******************************<BR> '* Local class definitions. *<BR> '******************************************** *******************************<BR><BR> '---------------------------------------------------------------------------<BR> ' TeamObj: Used to hold data for a single team.<BR> '---------------------------------------------------------------------------<BR><BR> class TeamObj<BR><BR> public id, name, division, conference<BR><BR> public totalWins, totalLosses, totalTies<BR> public homeWins, homeLosses, homeTies<BR> public roadWins, roadLosses, roadTies<BR><BR><BR> public totalPct, confPct, divPct<BR><BR> public streak<BR><BR> public pointsFor, pointsAgainst<BR><BR> public netPts, confNetPts<BR><BR> public allOpponents<BR> public allOppNetPts<BR> public oppWonAgainst, oppLostTo, oppTiedWith<BR><BR> public divWinner<BR> public tb, tb1, tb2, tb3, tbText<BR><BR> private sub Class_Initialize()<BR><BR> totalWins = 0 : totalLosses = 0 : totalTies = 0<BR> homeWins = 0 : homeLosses = 0 : homeTies = 0<BR> roadWins = 0 : roadLosses = 0 : roadTies = 0<BR><BR> totalPct = 0 : confPct = 0 : divPct = 0<BR><BR> streak = ""<BR><BR> pointsFor = 0 : pointsAgainst = 0<BR><BR> netPts = 0 : confNetPts = 0<BR><BR> allOpponents = Array() : allOppNetPts = Array()<BR><BR> oppWonAgainst = Array() : oppLostTo = Array() : oppTiedWith = Array()<BR><BR><BR><BR><BR> end sub<BR><BR> private sub Class_Terminate()<BR> end sub<BR><BR> public sub setData(teamID)<BR><BR> dim sql, rs<BR> dim opponentID<BR> dim ptDiff<BR> dim i<BR> dim currentStreak<BR><BR> id = teamID<BR><BR> 'Get team conference, division and display name.<BR><BR> sql = "select * " _<BR> & " from Teams1920 " _<BR> & " where TeamID = '" & teamID & "'" _<BR> & " and League = 'NFL'" <BR> set rs = DbConn.Execute(sql)<BR> if not (rs.BOF and rs.EOF) then<BR> conference = rs.Fields("Conference").Value<BR> division = rs.Fields("Division").Value<BR> League = rs.Fields("League").value<BR> if rs.Fields("DisplayName") <> "" then<BR> name = rs.Fields("DisplayName").Value<BR> else<BR> name = rs.Fields("City").Value<BR> end if<BR> end if<BR><BR> 'Find records and point totals for all games played by this team.<BR><BR> sql = "select * from Teams1920, Schedule1920" _<BR> & " where GameType = 'Reg'" _<BR> & " and Schedule1920.Season = 1920" _<BR> & " And Result <> ''" _<BR> & " and" _<BR> & " ((VisitorID = '" & teamID & "' and TeamID = HomeID)" _<BR> & " or" _<BR> & " (HomeID = '" & teamID & "' and TeamID = VisitorID))" _<BR> & " order by Week"<BR> set rs = DbConn.Execute(sql)<BR> if not (rs.BOF and rs.EOF) then<BR> currentStreak = ""<BR> do while not rs.EOF<BR><BR> 'Get the opponent team id and add to the team's opponents list.<BR> 'Also, add net points to the parallel array.<BR><BR> if rs.Fields("HomeID").Value = teamID then<BR> opponentID = rs.Fields("VisitorID").Value<BR> ptDiff = rs.Fields("HomeScore") - rs.Fields("VisitorScore")<BR> else<BR> opponentID = rs.Fields("HomeID").Value<BR> ptDiff = rs.Fields("VisitorScore") - rs.Fields("HomeScore")<BR> end if<BR> redim preserve allOpponents(Ubound(allOpponents) + 1)<BR> allOpponents(Ubound(allOpponents)) = opponentID<BR> redim preserve allOppNetPts(Ubound(allOppNetPts) + 1)<BR> allOppNetPts(Ubound(allOppNetPts)) = netPts<BR><BR> 'Add scores to points for and against totals.<BR><BR> if rs.Fields("VisitorID").Value = teamID then<BR> pointsFor = pointsFor + rs.Fields("VisitorScore").Value<BR> pointsAgainst = pointsAgainst + rs.Fields("HomeScore").Value<BR> else<BR> pointsFor = pointsFor + rs.Fields("HomeScore").Value<BR> pointsAgainst = pointsAgainst + rs.Fields("VisitorScore").Value<BR> end if<BR><BR> 'Add to the conference and overall net point totals.<BR> if rs.Fields("Conference").Value = conference then<BR> confNetPts = confNetPts + ptDiff<BR> end if<BR> netPts = netPts + ptDiff<BR><BR> 'Record a win.<BR><BR> if rs.Fields("Result").Value = teamID then<BR> totalWins = totalWins + 1<BR> if currentStreak <> "W" then<BR> currentStreak = "W"<BR> s