Problem solve Get help with specific problems with your technologies, process and projects.

Avoiding the 'subscript out of range' error

I want to add code to the queryopen event to examine the value(s) of certain fields in the document being opened to see if the document should be allowed to be edited. A couple of the fields being examined may contain multiple values. How can I avoid a 'subscript out of range' error if I don't know how many values there may be?
Based on the question, I am assuming you are using LotusScript. You can avoid using subscripts by using the ForAll statement:
  Dim doc As NotesDocument
  '...set value of doc...
  Dim item As NotesItem
  Set item = doc.GetFirstItem
( "FieldToBeTested" )
  Forall v In item.Values
    '...code your test here
  End Forall

Do you have comments on this Ask the Expert question and response? Let us know.

Dig Deeper on LotusScript

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...