Trying to put all names in an array

I am having a problem with this code, this code loops for all supervisors from the InitializeSupervisors() function.

The names of those supervisors are put in the recipients array, every time the second FOR is ran the information in the recipients is overridden there after the email is only sent to the last group of names… How can I have all of the Names in the recipients array before sending the email?

Call InitializeSupervisors ()

For counter = Lbound(Supervisors) To Ubound(Supervisors)

	

	recipientsCount = 0

	

	sCons_Need = doc.GetItemValue(Supervisors (counter, 2))

	sRiskIndicator = doc.GetItemValue(Supervisors (counter, 3))

	sResult = Approvalcheck(sCons_Need(0), sRiskIndicator(0))

	If sResult = "Waiting" Then			

		

		SupervisorsName = doc.GetItemValue(Supervisors (counter, 4))

		

		Redim recipients (1 To Ubound(SupervisorsName) +1 , recipientsCount)  

		

		recipientsCountA = 1 

		For x = 0 To Ubound(SupervisorsName) 

			recipients(recipientsCountA, recipientsCount) = SupervisorsName(x)	  

			recipientsCountA = recipientsCountA +1

		Next x  

		

		Set memItem = doc.getfirstitem(Supervisors (counter, 5))

		

		Forall n In SupervisorsName 

			Call memItem.appendtotextlist(n)

		End Forall

		Call memItem.appendtotextlist("  " + Today)

		

		recipientsCount = (recipientsCount + 1)

		sSendReminder = "Yes"

		



		If sSendReminder = "Yes" Then 

			Call SendSupervisorsReminder(recipients, doc, MessageToSend)			

		End If

		

	End If

Next

Thanks,

Paul,

Subject: Trying to put all names in an array…

Possibly try Redim Preserve? Not sure if it applies to your situation as I have not looked too deeply into it but take a look in designer help and see if this applies to your problem.

Subject: RE: Trying to put all names in an array…

thanks, but I tried that … did not seem to work.

Somehow I need to move this line “recipients(recipientsCountA, recipientsCount) = SupervisorsName(x) “ to just before sending the document “recipients(recipientsCountA, recipientsCount) = SupervisorsName(x)” and have a temp holding all of the SupervisorsName , I tried using SupNames = SupNames + SupervisorsName(x)

That did not work………

For x = 0 To Ubound(SupervisorsName)

recipients(recipientsCountA, recipientsCount) = SupervisorsName(x) ‘’’’’’’’’’’’’’’’’’

recipientsCountA = recipientsCountA +1

Next x

Set memItem = doc.getfirstitem(Supervisors (counter, 5))

Forall n In SupervisorsName

Call memItem.appendtotextlist(n)

End Forall

Call memItem.appendtotextlist(" " + Today)

recipientsCount = (recipientsCount + 1)

sSendReminder = “Yes”

If sSendReminder = “Yes” Then

Call recipients(recipientsCountA, recipientsCount) = SupervisorsName(x) (recipients, doc, MessageToSend)

End If