jforget1
asked on
Subscript Ran out of Range error
Have an agent that is used to send out notices 30 days before a device needs to be replaced. This agant has been running perfectly for about a year up until last month. Not sure what went wrong as I have not made any changes that should have had any impact. Had not touched the agent since it first started working.
In running thru debugger I get an error "Subscript out of Range" and I am not sure why. After running it lands on the line below. I am going to check the field values above that to see if there are any that are out of order.
monthly_tax_amt(arraycount ) = ventry.columnvalues(8)
In running thru debugger I get an error "Subscript out of Range" and I am not sure why. After running it lands on the line below. I am going to check the field values above that to see if there are any that are out of order.
monthly_tax_amt(arraycount
Options:
Option Public
Option Declare
Declarations:
Dim db As NotesDatabase
Dim v As notesview
Dim ventry As notesviewentry
Dim vnav As notesviewnavigator
Dim doc As notesdocument
Dim svc_tag() As String
Dim myuserid() As String
Dim dai() As String
Dim lease_term_date() As String
Dim lease_buyout_date() As String
Dim monthly_lease_amt() As String
Dim monthly_tax_amt() As String
Dim emaildoc As NotesDocument
Dim saveoffice As String
Dim arraycount As Integer
Initialize
Sub Initialize
Dim s As New NotesSession
Set db = s.CurrentDatabase
Set v = db.getview("(30_days)")
Set vnav = v.createviewnav
Set ventry = vnav.getfirst
'Process uniform information for all docs in office
Do Until ventry Is Nothing
' Build the top of the document
arraycount = 0
saveoffice = ventry.columnvalues(0)
Set emaildoc = db.CreateDocument
emaildoc.form = "30_day_reminder" 'Form name of Letter
Emaildoc.SendTo = ventry.columnvalues(1)
' Emaildoc.CopyTo = ventry.columnvalues(3)
Emaildoc.BlindCopyTo = "Field Technology"
ProcessEntry:
Call RedimArrays
dai(arraycount) = ventry.columnvalues(2)
myuserid(arraycount) = ventry.columnvalues(3)
svc_tag(arraycount) = ventry.columnvalues(4)
lease_term_date(arraycount) = ventry.columnvalues(5)
lease_buyout_date(arraycount) = ventry.columnvalues(6)
monthly_lease_amt(arraycount) = ventry.columnvalues(7)
monthly_tax_amt(arraycount) = ventry.columnvalues(8)
Arraycount = arraycount + 1
' Set flag on original document being processed
Set doc = ventry.document
doc.t30_flag = "done"
Call doc.save(True, True)
Set ventry = vnav.getnext(ventry)
If ventry Is Nothing Then Goto WriteLast
If ventry.columnvalues(0) = saveoffice Then
Goto ProcessEntry
Else
WriteLast:
emaildoc.username = myuserid
emaildoc.dai = dai
emaildoc.svc_tag = svc_tag
emaildoc.lease_term_date= lease_term_date
emaildoc.lease_buyout_date = lease_buyout_date
emaildoc.monthly_lease_amt = monthly_lease_amt
emaildoc.monthly_tax_amt = monthly_tax_amt
emaildoc.Principal = "Field Technology"
emaildoc.Subject ="NEF PC End of Lease in 30 days - Please Review!"
Call emaildoc.send(True)
arraycount = 0
Call CleanArrays
End If
Loop
End Sub
ReDimArrays:
Sub RedimArrays
Redim Preserve myuserid(arraycount) As String
Redim Preserve svc_tag(arraycount) As String
Redim Preserve dai(arraycount) As String
Redim Preserve lease_term_date(arraycount) As String
Redim Preserve lease_buyout_date(arraycount) As String
Redim Preserve monthly_lease_amt(arraycount) As String
Redim Preserve monthly_tax_amt(arraycount) As String
End Sub
Clean Arrays:
Sub CleanArrays
Redim myuserid(arraycount) As String
Redim svc_tag(arraycount) As String
Redim dai(arraycount) As String
Redim lease_term_date(arraycount) As String
Redim lease_buyout_date(arraycount) As String
Redim monthly_lease_amt(arraycount) As String
Redim monthly_tax_amt(arraycount) As String
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does it complete the loop at all? that is, does at least one doc get emailed or is it failing on the first run at the loop
ASKER
It is failing without sending even one of the emails. I tried deleting the first record that it runs but it is failing on, but it is still failing. Thought the record may have gotten corrupted.
Very strange. I would comment out the line and see if it runs. However probably also comment out the Call emaildoc.sent(True) just so that it does not actually email anyone ;-)
The error message does not suggest a view column error but I can not see anything else that appears wrong with the code. In counting to the 8th column in the view, make sure you do not count any columns that have constants, and also some UI formulas (like @DocNum). I know you say the view has not changed but just in case !!
The error message does not suggest a view column error but I can not see anything else that appears wrong with the code. In counting to the 8th column in the view, make sure you do not count any columns that have constants, and also some UI formulas (like @DocNum). I know you say the view has not changed but just in case !!
Oh, also comment out the doc.save for setting the flag!
ASKER
Tried one thing here, I had 55 records that should have gone out in February, I thought somethinf about these records may have caused an issue. I then ran the agent on the remaining 54 records that would have gone out 3/1. Got the same subscript error. Gonna do some testing taking out the last column of data that might be the culprit.
ASKER
Figured it out, and daj you were tight, I had added the tax amt to the letter that goes out a couple months back and I had it in all the code of the agent but I forgot to add it as the last column in the view. Stupid mistake that I should have picked up. Appreciate the help here.
ASKER