OK 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.

Basically this is a truck scheduling application which builds a layer for

each schedule of each truck from Monday thru Sunday.

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.

You'll notice from 3 trucks on, the layer widths are the same.

Can someone guide me on how I can convert this to a loop to cut down the

amount of code?

Thanks in advance!

<% '############## SET DIV WIDTH DETERMINED BY TRUCK COUNT

If myRS("TruckTota l") = 1 then

response.write "132"

ElseIf myRS("TruckTota l") = 2 then

response.write "67"

ElseIf myRS("TruckTota l") = 3 then

response.write "35"

ElseIf myRS("TruckTota l") > 3 then

response.write "35"

End If

%>px;

<%

'############## Grab Day, Truck # and position div horizontally

#############

'############## ############### ####### 1 Truck ###

'###Monday

If myRS("TruckTota l") = 1 then

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then

If myRS2("TruckInd ex")="1" then

response.write "left: 42px;"

end if

end if

'###Tuesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then

If myRS2("TruckInd ex")="1" then

response.write "left: 173px;"

end if

end if

'###Wednesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then

If myRS2("TruckInd ex")="1" then

response.write "left: 304px;"

end if

end if

'###Thursday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then

If myRS2("TruckInd ex")="1" then

response.write "left: 435px;"

end if

end if

'###Friday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then

If myRS2("TruckInd ex")="1" then

response.write "left: 566px;"

end if

end if

'###Saturday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then

If myRS2("TruckInd ex")="1" then

response.write "left: 697px;"

end if

end if

'###Sunday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then

If myRS2("TruckInd ex")="1" then

response.write "left: 828px;"

end if

end if

end if

'############## ############## 2 Trucks ###

'###Monday

If myRS("TruckTota l") = 2 then

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then

If myRS2("TruckInd ex")="1" then

response.write "left: 42px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 108px;"

end if

end if

'###Tuesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then

If myRS2("TruckInd ex")="1" then

response.write "left: 174px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 240px;"

end if

end if

'###Wednesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then

If myRS2("TruckInd ex")="1" then

response.write "left: 306px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 372px;"

end if

end if

'###Thursday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then

If myRS2("TruckInd ex")="1" then

response.write "left: 438px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 504px;"

end if

end if

'###Friday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then

If myRS2("TruckInd ex")="1" then

response.write "left: 570px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 636px;"

end if

end if

'###Saturday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then

If myRS2("TruckInd ex")="1" then

response.write "left: 702px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 768px;"

end if

end if

'###Sunday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then

If myRS2("TruckInd ex")="1" then

response.write "left: 834px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 900px;"

end if

end if

end if

'############## ########### 3 Trucks ###

'###Monday

If myRS("TruckTota l") = 3 then

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then

If myRS2("TruckInd ex")="1" then

response.write "left: 42px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 76px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 110px;"

end if

end if

'###Tuesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then

If myRS2("TruckInd ex")="1" then

response.write "left: 144px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 178px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 212px;"

end if

end if

'###Wednesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then

If myRS2("TruckInd ex")="1" then

response.write "left: 246px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 280px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 314px;"

end if

end if

'###Thursday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then

If myRS2("TruckInd ex")="1" then

response.write "left: 348px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left:382px ;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 416px;"

end if

end if

'###Friday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then

If myRS2("TruckInd ex")="1" then

response.write "left: 450px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 484px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 518px;"

end if

end if

'###Saturday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then

If myRS2("TruckInd ex")="1" then

response.write "left: 552px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 586px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 620px;"

end if

end if

'###Sunday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then

If myRS2("TruckInd ex")="1" then

response.write "left: 654px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 688px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 722px;"

end if

end if

end if

'############## ########### 4 Trucks ###

'###Monday

If myRS("TruckTota l") = 4 then

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then

If myRS2("TruckInd ex")="1" then

response.write "left: 42px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 76px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 110px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 144px;"

end if

end if

'###Tuesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then

If myRS2("TruckInd ex")="1" then

response.write "left: 178px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 212px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 246px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 280px;"

end if

end if

'###Wednesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then

If myRS2("TruckInd ex")="1" then

response.write "left: 314px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 348px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 382px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 416px;"

end if

end if

'###Thursday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then

If myRS2("TruckInd ex")="1" then

response.write "left: 450px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left:484px ;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 518px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 552px;"

end if

end if

'###Friday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then

If myRS2("TruckInd ex")="1" then

response.write "left: 586px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 620px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 654px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 688px;"

end if

end if

'###Saturday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then

If myRS2("TruckInd ex")="1" then

response.write "left: 722px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 756px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 790px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 824px;"

end if

end if

'###Sunday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then

If myRS2("TruckInd ex")="1" then

response.write "left: 858px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 892px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 926px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 960px;"

end if

end if

end if

'############## ########### 5 Trucks ###

'###Monday

If myRS("TruckTota l") = 5 then

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then

If myRS2("TruckInd ex")="1" then

response.write "left: 42px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 76px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 110px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 144px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 178px;"

end if

end if

'###Tuesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then

If myRS2("TruckInd ex")="1" then

response.write "left: 212px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 246px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 280px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 314px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 348px;"

end if

end if

'###Wednesday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then

If myRS2("TruckInd ex")="1" then

response.write "left: 382px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 416px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 450px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 484px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 518px;"

end if

end if

'###Thursday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then

If myRS2("TruckInd ex")="1" then

response.write "left: 552px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left:586px ;"

elseif myRS2("TruckInd ex")="3" then

response.write "left:6208p x;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 654px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 688px;"

end if

end if

'###Friday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then

If myRS2("TruckInd ex")="1" then

response.write "left: 722px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 756px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 790px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 824px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 858px;"

end if

end if

'###Saturday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then

If myRS2("TruckInd ex")="1" then

response.write "left: 892px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 926px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 960px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 994px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 1028px;"

end if

end if

'###Sunday

If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then

If myRS2("TruckInd ex")="1" then

response.write "left: 1062px;"

elseif myRS2("TruckInd ex")="2" then

response.write "left: 1096px;"

elseif myRS2("TruckInd ex")="3" then

response.write "left: 1130px;"

elseif myRS2("TruckInd ex")="4" then

response.write "left: 1164px;"

elseif myRS2("TruckInd ex")="5" then

response.write "left: 1198px;"

end if

end if

end if

'######## AND SO ON TILL 20 TRUCKS REACHED