| Author |
Topic Search Topic Options
|
KCWebMonkey
Senior Member
Go Chiefs!
Joined: 21 June 2002
Status: Offline
Points: 1319
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
aalavar
Groupie
Joined: 08 December 2003
Status: Offline
Points: 46
|
Post Options
Thanks(0)
Quote Reply
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.
|
 |
KCWebMonkey
Senior Member
Go Chiefs!
Joined: 21 June 2002
Status: Offline
Points: 1319
|
Post Options
Thanks(0)
Quote Reply
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]'
|
 |
aalavar
Groupie
Joined: 08 December 2003
Status: Offline
Points: 46
|
Post Options
Thanks(0)
Quote Reply
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]'
|
 |
KCWebMonkey
Senior Member
Go Chiefs!
Joined: 21 June 2002
Status: Offline
Points: 1319
|
Post Options
Thanks(0)
Quote Reply
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...
Boy, that was a dumb response I got to delete.... Let's try this again. |
What did you mean by that?
Edited by KCWebMonkey
|
 |
KCWebMonkey
Senior Member
Go Chiefs!
Joined: 21 June 2002
Status: Offline
Points: 1319
|
Post Options
Thanks(0)
Quote Reply
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...)
|
 |
pmormr
Senior Member
Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2003 at 2:00pm |
it happens to the best of us...
|
|
|
 |
aalavar
Groupie
Joined: 08 December 2003
Status: Offline
Points: 46
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2003 at 6:29pm |
KCWebMonkey wrote:
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 )
|
 |