Ive got a huge amount of If Then statements that Im sure can be stripped way down to a simple loop or two but Im not familiar enough with them to know where to start.<BR>Basically this is a truck scheduling application which builds a layer for each schedule of each truck from Monday thru Sunday.<BR>Below are the statements I have so far and I need to go up to 20 trucks. I think you'll be able to tell what Im trying to do.<BR>You'll notice from 3 trucks on, the layer widths are the same.<BR><BR>Can someone help me convert this to a loop to cut down the amount of code? Ive looked at Case but not sure where to start.<BR><BR>Thanks in advance!<BR><BR><% '############## SET DIV WIDTH DETERMINED BY TRUCK COUNT<BR>If myRS("TruckTotal") = 1 then<BR>response.write "132px;"<BR>ElseIf myRS("TruckTotal") = 2 then<BR>response.write "67px;"<BR>ElseIf myRS("TruckTotal") = 3 then<BR>response.write "35px;"<BR>ElseIf myRS("TruckTotal") > 3 then<BR>response.write "35px;"<BR>End If<BR><BR>'############## Grab Day, Truck # and position div horizontally <BR>'#################################### 1 Truck ###<BR>'###Monday<BR>If myRS("TruckTotal") = 1 then<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 42px;"<BR> end if<BR> end if<BR>'###Tuesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 173px;"<BR> end if<BR> end if<BR>'###Wednesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 304px;"<BR> end if<BR> end if<BR>'###Thursday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 435px;"<BR> end if<BR> end if<BR>'###Friday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 566px;"<BR> end if<BR> end if<BR>'###Saturday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 697px;"<BR> end if<BR> end if<BR>'###Sunday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 828px;"<BR> end if<BR> end if<BR>end if<BR><BR>'############################ 2 Trucks ###<BR>'###Monday<BR>If myRS("TruckTotal") = 2 then<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 42px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 108px;"<BR> end if<BR> end if<BR>'###Tuesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 174px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 240px;"<BR> end if<BR> end if<BR>'###Wednesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 306px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 372px;"<BR> end if<BR> end if<BR>'###Thursday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 438px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 504px;"<BR> end if<BR> end if<BR>'###Friday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 570px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 636px;"<BR> end if<BR> end if<BR>'###Saturday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 702px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 768px;"<BR> end if<BR> end if<BR>'###Sunday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 834px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 900px;"<BR> end if<BR> end if<BR>end if<BR><BR>'######################### 3 Trucks ###<BR>'###Monday<BR>If myRS("TruckTotal") = 3 then<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 42px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 76px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 110px;"<BR> end if<BR> end if<BR>'###Tuesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 144px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 178px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 212px;"<BR> end if<BR> end if<BR>'###Wednesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 246px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 280px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 314px;"<BR> end if<BR> end if<BR>'###Thursday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 348px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left:382px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 416px;"<BR> end if<BR> end if<BR>'###Friday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 450px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 484px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 518px;"<BR> end if<BR> end if<BR>'###Saturday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 552px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 586px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 620px;"<BR> end if<BR> end if<BR>'###Sunday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 654px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 688px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 722px;"<BR> end if<BR> end if<BR>end if<BR><BR>'######################### 4 Trucks ###<BR>'###Monday<BR>If myRS("TruckTotal") = 4 then<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 42px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 76px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 110px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 144px;"<BR><BR> end if<BR> end if<BR>'###Tuesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 178px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 212px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 246px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 280px;"<BR> end if<BR> end if<BR>'###Wednesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 314px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 348px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 382px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 416px;"<BR> end if<BR> end if<BR>'###Thursday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 450px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left:484px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 518px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 552px;"<BR> end if<BR> end if<BR>'###Friday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 586px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 620px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 654px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 688px;"<BR> end if<BR> end if<BR>'###Saturday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 722px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 756px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 790px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 824px;"<BR> end if<BR> end if<BR>'###Sunday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 858px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 892px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 926px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 960px;"<BR> end if<BR> end if<BR>end if<BR><BR>'######################### 5 Trucks ###<BR>'###Monday<BR>If myRS("TruckTotal") = 5 then<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 42px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 76px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 110px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 144px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 178px;"<BR><BR> end if<BR> end if<BR>'###Tuesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 212px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 246px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 280px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 314px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 348px;"<BR> end if<BR> end if<BR>'###Wednesday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 382px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 416px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 450px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 484px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 518px;"<BR> end if<BR> end if<BR>'###Thursday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 552px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left:586px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left:620px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 654px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 688px;"<BR> end if<BR> end if<BR>'###Friday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 722px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 756px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 790px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 824px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 858px;"<BR> end if<BR> end if<BR>'###Saturday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 892px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 926px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 960px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 994px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 1028px;"<BR> end if<BR> end if<BR>'###Sunday<BR> If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then<BR> If myRS2("TruckIndex")="1" then<BR> response.write "left: 1062px;"<BR> elseif myRS2("TruckIndex")="2" then<BR> response.write "left: 1096px;"<BR> elseif myRS2("TruckIndex")="3" then<BR> response.write "left: 1130px;"<BR> elseif myRS2("TruckIndex")="4" then<BR> response.write "left: 1164px;"<BR> elseif myRS2("TruckIndex")="5" then<BR> response.write "left: 1198px;"<BR> end if<BR> end if<BR>end if<BR>'######## AND SO ON TILL 20 TRUCKS REACHED<BR><BR>