Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Subscript out of range
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Subscript out of range

 Post Reply Post Reply Page  12>
Author
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Topic: Subscript out of range
    Posted: 09 December 2003 at 7:10am

I have a form that updates many records at once, looping through the records. It all works fine execpt for one field which gives the following error:

Microsoft VBScript runtime error '800a0009'
Subscript out of range: '0'
/dcsp/newCati/adminEmployeesFunction.asp, line 60

Line 60 has been highlighted below:

  For i = LBound(arrID_Num) To UBound(arrID_Num)
   Set editConn = Server.CreateObject("ADODB.Connection")
   editStrDbPathAndName = Server.MapPath("db/catiDb.mdb")
   editStrCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & editStrDbPathAndName
   editConn.ConnectionString = editStrCon
   editConn.open
   sqlQuery = "SELECT Users.* FROM Users WHERE ID_Num=" & arrId_Num(i)
   rsEmployees.CursorType = 2
   rsEmployees.LockType = 3
   rsEmployees.Open sqlQuery, editConn
   IF IsNumeric(arrPC_Num(i)) Then
    rsEmployees.Fields("PC_Num") = CLng(arrPC_Num(i))
   End If
   rsEmployees.Fields("First_Name") = arrFirst_Name(i)
   rsEmployees.Fields("Last_Name") = arrLast_Name(i)
   rsEmployees.Fields("Initials") = arrInitials(i)
   rsEmployees.Fields("User_Name") = arrUser_Name(i)
   IF IsNumeric(arrExtension(i)) Then
    rsEmployees.Fields("Extension") = arrExtension(i)
   End If
   rsEmployees.Fields("Supervisor") = arrSupervisor(i)
   rsEmployees.Update
   editConn.Close
   Set editConn = Nothing
  Next

 

If i comment out that line then all the other fields update correctly.

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 11:03am

Sounds like a dumb question, but are you sure you set the array to start at 0 for arrUser_Name?

i.e. try doing rsEmployees.Fields("User_Name") = arrUser_Name(i+1)  and see what happens.

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 11:28am

This is what i use for the array:

Dim arrUser_Name
arrUser_Name = Split (Request.Form("User_Name"), ", ")

If I change the code like you showed, i get the same error, except that the '0' changes to '[number: 1]'

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 1:09pm

Boy, that was a dumb response I got to delete.... Let's try this again.

The only way I can duplicate this error(or come close), is when the field is blank.  Are you sure there is data for all of the user names?

If I try:  

arrUser_Name = Split ("",", ")
Response.write arrUser_Name(0)

I get this error:

Microsoft VBScript runtime error '800a0009'

Subscript out of range: '[number: 0]'

 

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 1:19pm

I am sure that all the fields have data... and i even did this to verify that wasn't the problem:

If arrUser_Name(i) <> "" Then
  rsEmployees.Fields("User_Name") = arrUser_Name(i)
End If

Maybe the problem is that the values in the fields have underscores (_) in them?

 

and...

Quote Boy, that was a dumb response I got to delete.... Let's try this again.

What did you mean by that?



Edited by KCWebMonkey
Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 1:34pm

Holy crap..... i am an idiot... after checking on this for about 3 hours....

Come to find out, i had the field on the form named incorrectly

thanks aalavar for your help (unless you were calling me dumb earlier...)

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 2:00pm

it happens to the best of us...

Back to Top
aalavar View Drop Down
Groupie
Groupie


Joined: 08 December 2003
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote aalavar Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 6:29pm
Originally posted by KCWebMonkey KCWebMonkey wrote:

Quote Boy, that was a dumb response I got to delete.... Let's try this again.

What did you mean by that?

I responded, but it was dumb, and I corrected myself with the right question.  I wasn't calling you dumb, I was calling myself dumb! (Anyway, I can only delete my own posts, so I couldn't have deleted any other dumb posts )

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.