pdvsa
asked on
Script out of Range error
Experts, I keep getting this "Script out of Range" error in the below load Event. It seems to be something with the extra quote at the very end ((Me.OpenArgs, ";")(4) & ""). I delete this extra quote at the end but Access puts it back. Maybe there is a syntax elsewhere. Pay attn to the part after the LCNo in the Me.Filter part (because I added what is after it ;).
Do you see an issue with the Me.Filter part? I think it is in this section.
Do you see an issue with the Me.Filter part? I think it is in this section.
Private Sub Form_Load()
If Nz(Me.OpenArgs, "") <> "" Then
If Not Me.NewRecord Then
Me.Filter = "[letterofcreditID_Auto] = " & Split(Me.OpenArgs, ";")(0) & " AND [EndUserID] = " & Split(Me.OpenArgs, ";")(1) & " AND [LCNo] = " & Chr(34) & Split(Me.OpenArgs, ";")(2) & Chr(34) & " AND [PROJID] = " & Split(Me.OpenArgs, ";")(3) & " AND [Amount] = " & Split(Me.OpenArgs, ";")(4) & ""
Me.FilterOn = True
Else
'/this is a new record
MsgBox Split(Me.OpenArgs, ";")(4)
Me.LetterOfCreditID_Auto = Split(Me.OpenArgs, ";")(0)
Me.EndUserID = Split(Me.OpenArgs, ";")(1)
Me.LCNo = Split(Me.OpenArgs, ";")(2)
Me.ProjID = Split(Me.OpenArgs, ";")(3)
Me.Amount = Split(Me.OpenArgs, ";")(4)
End If
End If
End Sub
ASKER
Patrick, thank you. I will test when i return to my computer. Not sure if i will today though.
I've never seen Split used the way your syntax is written.
For readability and troubleshhoting I would try this
Now you can drop a breakpoint on every line and see where it's going wrong.
And you call Split once, which is more elegant and efficient
For readability and troubleshhoting I would try this
Private Sub Form_Load()
Dim MyOpenArgs() as string
MyOpenArgs() = Split(Me.OpenArgs, ";")
Dim myFilter as string
If Nz(Me.OpenArgs, "") <> "" Then
If Not Me.NewRecord Then
myFilter = "[letterofcreditID_Auto] = " & MyOpenArgs(0)
myFilter = myFilter & " AND [EndUserID] = " & MyOpenArgs(1)
myFilter = myFilter & " AND [LCNo] = " & Chr(34) & MyOpenArgs(2) & Chr(34)
myFilter = myFilter & " AND [PROJID] = " & MyOpenArgs(3)
myFilter = myFilter " AND [Amount] = " & MyOpenArgs(4)
Me.Filter = myFilter
Me.FilterOn = True
Else
'/this is a new record
msgbox MyOpenArgs(4)
Me.LetterOfCreditID_Auto = MyOpenArgs(0)
Me.EndUserID = MyOpenArgs(1)
Me.LCNo = MyOpenArgs(2)
Me.ProjID = MyOpenArgs(3)
Me.Amount = MyOpenArgs(4)
End If
End If
End Sub
Now you can drop a breakpoint on every line and see where it's going wrong.
And you call Split once, which is more elegant and efficient
ASKER
Patrick: it says there are 2 semicolons. Maybe this indicates there is a issue somewhere. I am thinking there needs to be more?
Nick: I seem to have a syntax error on this line:
myFilter = myFilter " AND [Amount] = " & MyOpenArgs(4)
let me know what is the next step.
Nick: I seem to have a syntax error on this line:
myFilter = myFilter " AND [Amount] = " & MyOpenArgs(4)
let me know what is the next step.
ASKER
I have ul the db. It might be easier to see instead of attempting by text.
It seems as though I still have the out of script range error even after copy and paste of Patrick's code. It might have something to do with the LCNo because you can see the number of digits this LCNo is once I hover over the yellow highlighted area in the code after the error. There seems to be many digits that should not be there. Ex: theh LC No is CPCS-787109 (just made it up) but it will add many digits after.
In the form that autoexec opens, please click on the buttton "evergreen" and you will get the error. If you dont get the error then maybe go to another record and click the button.
I am trying to add a record in tblAutoExtend_Evergreen after clicking on the button..
thank you
New---use-this-for-EE---Filter.zip
It seems as though I still have the out of script range error even after copy and paste of Patrick's code. It might have something to do with the LCNo because you can see the number of digits this LCNo is once I hover over the yellow highlighted area in the code after the error. There seems to be many digits that should not be there. Ex: theh LC No is CPCS-787109 (just made it up) but it will add many digits after.
In the form that autoexec opens, please click on the buttton "evergreen" and you will get the error. If you dont get the error then maybe go to another record and click the button.
I am trying to add a record in tblAutoExtend_Evergreen after clicking on the button..
thank you
New---use-this-for-EE---Filter.zip
ASKER
it is 2k7.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"I've never seen Split used the way your syntax is written."
Remember, Split () is an array. That syntax is referring to the 5 element (zero based). So, the syntax is ok. That's something I learned here about 3 years ago ... the first time I saw that also.
mx
Remember, Split () is an array. That syntax is referring to the 5 element (zero based). So, the syntax is ok. That's something I learned here about 3 years ago ... the first time I saw that also.
mx
ASKER
Darnit.... I missed that. I will test after awhile. Not at a computer now. Thank you... I did realize that the first answer was to diagnose and that it was a first step to a soln.
ASKER
I see now.... The fewer arguments were due to no separation between the fields with the ; (semicolon). I was missing the semicolon.
Will follow up if have more questions. Thank you
Will follow up if have more questions. Thank you
The subscript out of range error makes me think that the problem is with OpenArgs: specifically, that there are fewer than five items.
Please try this, and report back what you see:
Open in new window
If there are fewer than 4 semicolons, then that is your problem.
Patrick