dim total_tons(7)
is fine except it has 8 entries (arrays are 0 based). Show the code where the type mismatch occurs. It should not be occurring on the Dim.
It's pretty ugly, but here it is...I am still working on other parts of it so it isn't complete. The error is showing up on line 196, which is right below the dim total_tons(7) (it's at about the middle of the code, I *'d it for easier finding)
sub display_Data (fromdate, todate)
dim s, category(100), category_count, j, category_maxsub(100), colno, maxsub_for_all, k
category_count = 0
maxsub_for_all = -1
if fromdate = "" then
fromdate = formatDateTime(now(), vbShortDate)
end if
if todate = "" then
todate = formatDateTime(dateadd("d",14, now()), vbShortDate)
end if
'get number of categorys that we are going to be working with
s = ""
s = "select distinct wogrouprouting.category, Category.WKCDESC, Category.LINE, "
s = s & " Category.DAILYCAP, space(5 - len(wogrouprouting.category)) + wogrouprouting.category "
s = s & " from wogrouprouting , workCentre Category, workOrder "
s = s & " where wogrouprouting.wohno = WorkOrder.wohno and "
s = s & " wogrouprouting.category = Category.wkcntr and "
s = s & " wogrouprouting.category not in ('11','12','08') and "
's = s + " wogrouprouting.wkcntr in ('01A','01B') and "
s = s & " isnull(calcstartdate, getdate()) >= '" & fromdate & "' and "
s = s & " isnull(calcstartdate,getdate()) <= '" & todate & "'"
s = s & " order by wogrouprouting.category , space(5 - len(wogrouprouting.category)) + "
s = s & " wogrouprouting.category "
'Response.Write s & "<br>"
'ok fire up the select
s = ""
s = s & "select wogrouprouting.category, Category.wkcdesc, Category.line, Category.dailyCap, "
s = s & " rtrim(mandb100.envymgr.wohrec.prtno) prtno, "
s = s & " mandb100.envymgr.prtrec.prtdesc, rtrim(WorkOrder.wohno) wohno, WorkOrder.wopriority, "
s = s & " isnull(WorkOrder.calcStartDate, dateadd(day,-1, getdate())) calcstartdate, "
s = s & " cast ((mandb100.envymgr.wohrec.wohoqty - mandb100.envymgr.wohrec.wohcqty) * "
s = s & " mandb100.envymgr.prtrec.prtwgt / 2000 as decimal(13,3)) WO_Weight, "
s = s & " convert(datetime, cast(case mandb100.envymgr.wohrec.wohmrp when 0 then 19000101 "
s = s & " when 99999999 then 20991231 else mandb100.envymgr.wohrec.wohmrp end as char), 112) wohmrp, "
s = s & " mandb100.envymgr.wohrec.wohoqty, mandb100.envymgr.wohrec.wohcqty, "
s = s & " convert(datetime, cast(case mandb100.envymgr.wohrec.wohoddat when 0 then 19000101 when 99999999 "
s = s & " then 20991231 else mandb100.envymgr.wohrec.wohoddat end as char), 112) wohoddat "
s = s & " from wogrouprouting , workCentre Category, workOrder , mandb100.envymgr.prtrec , "
s = s & " mandb100.envymgr.wohrec "
s = s & " where wogrouprouting.wohno = WorkOrder.wohno and "
s = s & " WorkOrder.wohno = mandb100.envymgr.wohrec.wohno and mandb100.envymgr.wohrec.prtno = "
s = s & " mandb100.envymgr.prtrec.prtno and Category.wkcntr = wogrouprouting.category and "
s = s & " mandb100.envymgr.wohrec.wohoqty > mandb100.envymgr.wohrec.wohcqty and "
s = s & " mandb100.envymgr.wohrec.wohstat < 3 and "
s = s & " isnull(calcstartdate, getdate()) >= '" & fromdate & "' and "
s = s & " isnull(calcstartdate,getdate()) <= '" & todate & "' and "
's = s & " AND wogrouprouting.wkcntr in ('01A','01B') and "
s = s & " wogrouprouting.category not in ('11','12','08') "
s = s + " order by convert(char, isnull(WorkOrder.calcStartDate, "
s = s & " dateadd(day,-1, getdate())),20), Category.wkcntr, WorkOrder.wopriority desc,"
s = s + " (mandb100.envymgr.wohrec.wohoqty - mandb100.envymgr.wohrec.wohcqty) * "
s = s & " prtwgt / 2000 , WorkOrder.wohno"
'Response.Write (s & "<br>"
dbconnect connectString_corpdb, s
dim a(2000,100), lastdate, curdate, datearray(2000)
lastdate = ""
'Response.Write ("</table>"
while not oRS.eof
' what is the current date
'Response.Write (oRS("wohno".value & " " & formatDateTime(oRS(8).value, vbShortDate) & "<br>"
curdate = formatDateTime(oRS(8).value, vbShortDate)
if curdate <> lastdate then
'ok its a new day, all subscripts get set to current maximum
for j = 0 to category_count
category_maxsub(j) = maxsub_for_all
next
lastdate = curdate
end if
'figure out column of this category
colno = -1
for j = 0 to category_count
if category(j) = oRS(0).value then
colno = j
j = category_count+1
'Response.Write category(j) + " " + " " + oRS(0).value + "<br>"
end if
next
if colno < 0 then
Response.Write ("couldnt find category --" + oRS(0).value + "<br>"
end if
'ok now we have colno as a subscript to the column
category_maxsub(colno) = category_maxsub(colno) + 1
if category_maxsub(colno) > maxsub_for_all then
maxsub_for_all = category_maxsub(colno)
end if
if category_maxsub(colno) > maxsub_for_all then
maxsub_for_all = category_maxsub(colno)
end if
s = ""
's = s & "<a href=display_schedule_update.asp?" & oRS("wohno".value
s = s & "<a href=display_schedule_update2.asp?" & oRS("wohno".value
s = s & " target=_blank>" & oRS("wohno".value & "</a>, "
S = S & oRS("wohoqty".value & " - Qty"
if ors("wohcqty".value <> 0 then
s = s & "[" & ors("wohcqty".value & "] - rec"
end if
s = s & ", "
s = s & "<a name=""" & ors("prtno".value & """ href=""../PRTREC_dETAIL.ASP?" & oRS("prtno".value & """"
s = s & " target=_blank>" & oRS("prtno".value & "</a>, "
s = s & "p" & oRS("wopriority".value & ", "
s = s & formatNumber(oRS("wo_weight".value,1) & "T "
's = s & formatdatetime(oRS("calcstartdate".value, vbshortdate) & " "
if oRS("wohmrp".value <= datevalue(curdate) then
s = s & "<font color=#ff0000>" & "*" & formatdatetime(oRS("wohmrp".value, vbshortdate) & "</font>"
else
s = s & formatdatetime(oRS("wohmrp".value, vbshortdate)
end if
s = s & " - MRP "
s = s & "[" & formatdatetime(oRS("wohoddat".value, vbshortdate) & "]"
'***************************HERE IS WHERE THE TYPE MISMATCH ERROR IS OCCURING***************************
dim total_tons(7) 'array to hold the daily category tonnage
dim date_flag 'variable to indicate day that is currently being looked at
datearray(maxsub_for_all) = curdate
date_flag = ""
dim i, diff, new_weight
'if formatDateTime(oRS("calcstartdate".value), vbShortDate) < formatDateTime(now(), vbShortDate) then
'do nothing with these workorders (old)
'else if ors(0).value = "99" then
'do nothing with these workorders (unknown)
'else
'otherwise, it's current, so we'll deal with it
'if it's a new day (records sorted 1st by date)
if curdate <> date_flag then
for i = 0 to 7
'reset the daily category tonnage counters for the new day
total_tons(i) = 0.0
next
end if
'set the date_flag to the current day
date_flag = curdate
'find the right daily category tonnage counter to add to
for i = 0 to 7
if category(i) = oRS(0).value then
total_tons(i) = total_tons(i) + formatNumber(oRS("wo_weight".value,1)
'if it's over the daily capacity, move to next day(s)
if total_tons(i) > daily_cap(i) then
'so take it off this day's total
total_tons(i) = total_tons(i) - formatNumber(oRS("wo_weight".value, 1) 'and subtract it from the day's total
diff = daily_cap(i) - total_tons(i)
if diff = 0 then
'move the whole wo to next day
s = ""
s = s & "<a href=display_schedule_update2.asp?" & oRS("wohno".value
s = s & " target=_blank>" & oRS("wohno".value & "</a>, "
S = S & oRS("wohoqty".value & " - Qty"
if ors("wohcqty".value <> 0 then
s = s & "[" & ors("wohcqty".value & "] - rec"
end if
s = s & ", "
s = s & "<a name=""" & ors("prtno".value & """ href=""../PRTREC_dETAIL.ASP?" & oRS("prtno".value & """"
s = s & " target=_blank>" & oRS("prtno".value & "</a>, "
s = s & "p" & oRS("wopriority".value & ", "
s = s & formatNumber(oRS("wo_weight".value,1) & "T "
if oRS("wohmrp".value <= datevalue(curdate) then
s = s & "<font color=#ff0000>" & "*" & formatdatetime(oRS("wohmrp".value, vbshortdate) & "</font>"
else
s = s & formatdatetime(oRS("wohmrp".value, vbshortdate)
end if
s = s & " - MRP "
s = s & "[" & formatdatetime(oRS("wohoddat".value, vbshortdate) & "]"
Response.Write("</tr>"
lastdate = ""
for j = 0 to maxsub_for_all
Response.Write "<tr>"
if datearray(j) <> lastdate then
dim x
x = datevalue(datearray(j))
s = ""
s = weekdayName( weekday(x),true)
s = s + " " & Month(x) & "/" & day(x)
else
s = " "
end if
lastdate = datearray(j)
Response.Write("<td wrap><font size=2>" & s & "</font></td>"
for k = 0 to category_count
Response.Write("<td><font size=2>" & a(j,k) & " "& "</font></td>"
next
Response.Write ("</tr>"
next
response.write "</table>"
'end if
end sub
'******************************************************************
dim fromdate, todate
'determine default dates if there aren't any
fromdate = Request.Form("fromdate"
if fromdate = "" then
fromdate = formatDateTime(dateadd("d",-5, now()), vbShortDate)
end if
todate = Request.Form("todate"
if todate = "" then
todate = formatDateTime(dateadd("d",365, now()), vbShortDate)
end if
if not isdate(fromdate) then
Response.Write ("From date (" & fromdate & " is not valid. Use format of mm/dd/yyyy<br>"
end if
if not isdate(todate) then
Response.Write ("To date (" & todate & " is not valid. Use format of mm/dd/yyyy<br>"
end if
</head>
<body>
<font size="1">
From Date (mm/dd/yyyy): <input name="fromdate" size="10" value="<%=fromdate%>">
To Date: <input name="todate" size="10" value="<%=todate%>">
Recalculate: <input name="recalculate" type="checkbox">
<input type="submit" value="Submit" name="submitbutton">
</font>
</form>
<%
Response.Flush
if isdate(fromdate) and isdate(todate) then
if Request.form("recalculate" <> "" then
Response.Write("Starting Recalculate..."
Response.Flush
set oConn = server.CreateObject("ADODB.connection"
set oCmd = server.CreateObject("adodb.command"
oConn.open connectString_corpdb
set oCmd.activeConnection=oConn
oCmd.commandtext = "execute dbo.WORKoRDERsCHEDULECALCULATEg2"
oCMD.commandtype = adCmdtext
oCmd.execute
Response.Write("Finished.<br>"
Response.Flush
end if
display_data fromdate, todate
Response.Flush
end if
%>
</body></html>
I don't see an obvious error. Use the VARTYPE function to display the Data Type that is in a Variant. You will get an error if you moved a date to a variable then tried to set it to a string.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.