Question : Microsoft VBScript runtime error '800a0009', Subscript out of range: '42'

Hi Experts,

Please help I am getting Subscript out of range while running the application.

THis application is using VB Script & Classic ASP.

Microsoft VBScript runtime error '800a0009'

Subscript out of range: '42'

/Empserv/TotalComp/Export.asp, line 100


thanks
Dileep.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
<%@ Language=VBScript %>
<%option explicit
Response.CacheControl = "no-cache" 
Response.AddHeader "Pragma","no-cache" 
Response.Expires = -1 
Response.Buffer = True
'On error resume next

If Session("User") = "" then
	Response.Write "<html><head><title>Performance Partnership Timeout</title></head><body><br>"
	Response.Write "<div align=center style='color:red'><h2>Your Performance Partnership Session has timed out!</div></h2><hr><br><br><h3>Follow these instructions to reload login page:<br>after closing this window, refresh the <i>prior</i> window by pressing F5 on a PC or, if you are using a Mac, selecting the 'Refresh' option from the menu.<br><br></body></html>"
	Response.End 
ElseIf Application("Locked")=True Then
	Response.Write "<html><head><title>Performance Partnership Unavailable</title></head><body><br><h1><div align=center style='color:red'>Do not close this window!</div></h1><hr><br>"
	Response.Write "<h2>The Performance Partnership System is unavailable for a few minutes.</h2><br><h3><span style='color:red'>When the system is again available you will resume <b>exactly where you left off without any loss of information only if you follow the instructions below.</span></h3></b><h3><hr><br>1. Refresh this window by pressing F5 on a PC or, if you are using a Mac, selecting the 'Refresh' option from the menu.<br><br>2. Click 'Retry' if prompted.<br><br>3. Repeat steps 1 and 2 at least every few minutes until the system becomes available.<br></h2></body></html>"
	Response.End 
	
End if

Dim vExport,lngRandom,blnRetVal,obj,vDetail,objXL
%><html>
<head>
<!-- #INCLUDE FILE="../Common/ServerScripts/header.asp" -->
<!-- #INCLUDE FILE="../Common/Constants/Env.inc" -->
<!-- #INCLUDE FILE="../Common/ServerScripts/Navigation.asp" -->
<script LANGUAGE="JavaScript" SRC="../Common/ClientScripts/Common.js"></script>
<title>Export</title>
</head>
<body oncontextmenu="return true"><%

'Load the header
Call Load_Basic_Header("Export")

if Request.QueryString("Type") = "Select" Then
	Response.Write "<BR>Select an organization before exporting."
	Response.End 
end if

Response.write "<span id='sGetting' class='tSubHeadTxt'>Creating an Excel spreadsheet from the active selection....</span>"
Response.Flush 

vExport=Session("Export")
If IsEmpty(vExport) Then
		Response.Write "<br><span class='tSubHeadTxt'>This selection is not currently able to be exported</span>"
Else
	Response.Write("<br />")
        Response.Write("Export Functionality Started.")
	Randomize
	lngRandom = int((9000000000 - 1000000000 + 1) * Rnd + 1000000000)
	vExport(C_EXPORT_FILE_NAME)=CStr(vExport(C_EXPORT_PLAN)) & "_" & session.SessionID & "_" & lngRandom

	Set obj = Server.CreateObject("HRW_Execute.CExecute") 
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write vExport(C_EXPORT_QUERY)
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write(C_EXPORT_FIELDS)
		vDetail = obj.SelectRows(C_DB_NAME, C_RDAHR_ID,C_RDAHR_PW, vExport(C_EXPORT_QUERY), vExport(C_EXPORT_FIELDS))
	Set obj = Nothing
	Set objXL = CreateObject(C_TCP_EXPORT) 
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write(C_EXPORT_PLAN)
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write("First Time") + "<BR />"
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write (vExport(C_EXPORT_FILE_NAME) + "<BR />")
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write (vExport(c_EXPORT_PLAN) + "<BR />")
	Response.Write("<br />")
        Response.Write("<br />")
	vExport(C_EXPORT_FILE_NAME)=CStr(vExport(C_EXPORT_PLAN)) & "_" & session.SessionID & "_" & lngRandom
	'Response.Write("<br />")
        'Response.Write("<br />")
 	Response.Write("Second Time") + "<BR />"
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write (vExport(C_EXPORT_FILE_NAME) + "<BR />")
	Response.Write("<br />")
        Response.Write("<br />")
	Response.Write(CStr(vExport(C_EXPORT_PLAN)))
	Response.Write(CStr(Session("Pword")))
	Response.Write(C_EXPORT_FIELDS)
	'Response.Write(vDetail(0,0))
        Response.Write(C_TCP_EXPORT_DIR)
        Response.Write(vExport(C_EXPORT_FILE_NAME))
	Response.Write(vExport(C_EXPORT_FREQUENCY))
        'UBound(arrayname[,dimension]) 
	'arrayname Required. The name of the array variable 
        'dimension Optional. Which dimension's upper bound to return. 1 = first dimension, 2 = second dimension, and so on. Default is 1 
        'Here the array name is vDetail
        'Dimension is 2
	Dim i,j
	For i = 0 To ubound(vDetail,2)
		For j = 0 To ubound(vDetail,2)
 			Response.Write("The Value is " & vDetail(i,j) & "<br />")
	Next
	Next

	Select Case CStr(vExport(C_EXPORT_PLAN))	
		Case "Merit"
			blnRetVal = objXL.ExportMerit(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME),vExport(C_EXPORT_FREQUENCY))
			'vExport(C_EXPORT_FREQUENCY))
                        'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"
		Case "VCP"
			blnRetVal = objXL.ExportMIP(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME))
			'Response.Write blnRetVal + "<BR>"
			'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"		
		Case "AIP"
			blnRetVal = objXL.ExportAIP(Session("Pword"),vExport(C_EXPORT_PLAN),vDetail,C_TCP_EXPORT_DIR,vExport(C_EXPORT_FILE_NAME))		
			'Response.Write blnRetVal + "<BR>"
			'Response.Write "Value of blnRetVal is " + blnRetVal + "<BR>"
		Case Else
			Response.Write "<br><span class='tSubHeadTxt'>The " & vExport(C_EXPORT_PLAN) & " plan is not currently able to be exported</span>"
			Set objXL = nothing
			Response.End  
	End Select
	Set objXL = nothing

	If blnRetVal Then
		%><br><br><span class='tSubHeadTxt'>A Microsoft Excel spreadsheet has been created with real-time information. This spreadsheet has been protected with your Performance Partnership System password (in lower case). After opening the file, please save it to a local hard drive or floppy disk.</span><br><br>
		<span class='tSubHeadTxt'><A href='../Export/<%= vExport(C_EXPORT_FILE_NAME)%>.xls' target='sshet'><img border="0" SRC="../Common/Images/Report/ExcelIcon.gif" WIDTH="40" HEIGHT="40"></A>Click to open the spreadsheet or right-click for other options.</span><br><%
			
	Else
		Response.Write "<SCRIPT LANGUAGE=javascript>sGetting.innerHTML='An error occurred during spreadsheet creation.<br>Please contact user support.';</SCRIPT>"
		Response.End 
	End If
	
End If
%>
<SCRIPT LANGUAGE=javascript>sGetting.innerHTML="";</SCRIPT>
</body>
</html>

Answer : Microsoft VBScript runtime error '800a0009', Subscript out of range: '42'

What's HRW_Export_TCP2008_1?  Is that the DLL function?  This would mean that there's a problem in the DLL in the ExportMIP function.

It could be anywhere in there, because we're not told where it is.

What you might have to do is try and run the ExportMIP function in VBA with the same parameters that you have displayed above, and see when that errors.  Running the function independantly will give you the proper line number of the error itself.

The reason I think the error is in that function, is because the function call from your web page is passing the correct parameters, which all have valid values, as shown by the output.

Regards,

Rob.
Random Solutions  
 
programming4us programming4us