Getting stonewalled on variable call

Getting stonewalled on variable call

Hey,

Is there any reason why my function would say my variable is "not declared" even when it's clearly in the script? If I try to save the following script it states just that for 'maxweek1':

  1. void schedule_teams.mhl_scheduling_module.toString()
  2. {
  3.     for each r in MHL_Scheduling_Module  [(Season == "Winter 2013" && (Team_1 is null))] sort by  Team_1 
  4.     {
  5.         scheduleteam15  =  MHL_Team_Contact_Info_Entry  [((((Current_Last_Season_New == r.Season && Nights_Playing == r.Day) && Team_Name != "(Non-League Opponent)") && Team_Name != "(TBA)") && Rinks_Playing == r.Rink)];
  6.         r.Team_1 = scheduleteam15.Team_Name;
  7.         r.Team_1_Level = scheduleteam15.Level;
  8.         r.Team_1_Div = scheduleteam15.Division;
  9.         r.Team_1_Bal_Remain = scheduleteam15.Bal_Remain;
  10.         r.Team_1_Pct_Paid = scheduleteam15.Pct_Paid;
  11.         maxweek1 = MHL_Scheduling_Module[(r.Team_1 == r.Team_1 && r.Week == r.Week)].count();
  12.         if (maxweek1  >  1)
  13.         {
  14. r.Team_1 = maxweek1.Team_1;
  15.         }
  16.     }
  17. }

Any ideas on why this is happening?