CurrentWeek = DLookup("[Weekday]", "T_Today") Select Case CurrentWeek Case Is = 3 DoCmd.RunSQL "SELECT Q_DailyAutoSMAPendingNo3.UpdatedBy, Q_DailyAutoSMAPendingNo3.Name, Q_DailyAutoSMAPendingNo3.TLName, Q_DailyAutoSMAPendingNo3.Pending INTO Tmp FROM Q_DailyAutoSMAPendingNo3" DoCmd.RunSQL "INSERT INTO MonthlyAutoSMAResult ( [MA Initial], [Analyst Name], [Team Leader] ) SELECT Tmp.UpdatedBy, Tmp.Name,Tmp.TLName FROM Tmp" Call MonthlyAutoSMAResultDay Case Is = 4, 5, 6, 7 DoCmd.RunSQL "SELECT Q_DailyAutoSMAPendingNo.UpdatedBy, Q_DailyAutoSMAPendingNo.Name, Q_DailyAutoSMAPendingNo.TLName, Q_DailyAutoSMAPendingNo.Pending INTO Tmp FROM Q_DailyAutoSMAPendingNo" DoCmd.RunSQL "INSERT INTO MonthlyAutoSMAResult ( [MA Initial], [Analyst Name], [Team Leader] ) SELECT Tmp.UpdatedBy, Tmp.Name,Tmp.TLName FROM Tmp" Call MonthlyAutoSMAResultDay End Select End Sub Private Sub MonthlyAutoSMAResultDay() Dim CurrentDay DoCmd.RunSQL "UPDATE T_Today SET T_Today.Day = Format$([TodayDate],'d') WHERE (((T_Today.TodayDate) Is Not Null))" CurrentDay = DLookup("[Day]", "T_Today") Select Case CurrentDay Case Is = 1 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[1] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[1] = 0 WHERE (((MothlyAutoSMAResult.[1]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 2 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[2] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[2] = 0 WHERE (((MothlyAutoSMAResult.[2]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 3 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[3] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[3] = 0 WHERE (((MothlyAutoSMAResult.[3]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 4 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[4] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[4] = 0 WHERE (((MothlyAutoSMAResult.[4]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 5 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[5] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[5] = 0 WHERE (((MothlyAutoSMAResult.[5]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 6 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[6] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[6] = 0 WHERE (((MothlyAutoSMAResult.[6]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 7 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[7] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[7] = 0 WHERE (((MothlyAutoSMAResult.[7]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 8 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[8] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[8] = 0 WHERE (((MothlyAutoSMAResult.[8]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 9 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[9] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[9] = 0 WHERE (((MothlyAutoSMAResult.[9]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 10 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[10] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[10] = 0 WHERE (((MothlyAutoSMAResult.[10]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 11 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[11] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[11] = 0 WHERE (((MothlyAutoSMAResult.[11]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 12 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[12] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[12] = 0 WHERE (((MothlyAutoSMAResult.[12]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 13 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[13]= [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[13] = 0 WHERE (((MothlyAutoSMAResult.[13]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 14 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[14] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[14] = 0 WHERE (((MothlyAutoSMAResult.[14]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 15 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[15] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[15] = 0 WHERE (((MothlyAutoSMAResult.[15]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 16 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[16] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[16] = 0 WHERE (((MothlyAutoSMAResult.[16]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 17 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[17] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[17] = 0 WHERE (((MothlyAutoSMAResult.[17]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 18 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[18] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[18] = 0 WHERE (((MothlyAutoSMAResult.[18]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 19 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[19] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[19] = 0 WHERE (((MothlyAutoSMAResult.[19]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 20 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[20] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[20] = 0 WHERE (((MothlyAutoSMAResult.[20]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 21 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[21] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[21] = 0 WHERE (((MothlyAutoSMAResult.[21]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 22 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[22] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[22] = 0 WHERE (((MothlyAutoSMAResult.[22]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 23 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[23] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonhlyAutoSMAResult.[23] = 0 WHERE (((MothlyAutoSMAResult.[23]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 24 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[24] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[24] = 0 WHERE (((MothlyAutoSMAResult.[24]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 25 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[25] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[25] = 0 WHERE (((MothlyAutoSMAResult.[25]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 26 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[26] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[26] = 0 WHERE (((MothlyAutoSMAResult.[26]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 27 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[27] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[27] = 0 WHERE (((MothlyAutoSMAResult.[27]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 28 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[28] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[28] = 0 WHERE (((MothlyAutoSMAResult.[28]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 29 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[29] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[29] = 0 WHERE (((MothlyAutoSMAResult.[29]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 30 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[30] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[30] = 0 WHERE (((MothlyAutoSMAResult.[30]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" Case Is = 31 DoCmd.RunSQL "UPDATE Tmp INNER JOIN MonthlyAutoSMAResult ON (Tmp.TLName = MonthlyAutoSMAResult.[Team Leader]) AND (Tmp.Name = MonthlyAutoSMAResult.[Analyst Name]) AND (Tmp.UpdatedBy = MonthlyAutoSMAResult.[MA Initial]) SET MonthlyAutoSMAResult.[31] = [Tmp]![Pending] WHERE (((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" DoCmd.RunSQL "UPDATE MonthlyAutoSMAResult SET MonthlyAutoSMAResult.[31] = 0 WHERE (((MothlyAutoSMAResult.[31]) Is Null) AND ((MonthlyAutoSMAResult.[MA Initial]) Is Not Null))" End Select End Sub