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



  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...