Hi, i've written some code to automatically send out reports by e-mail (using Groupwise). Each report sends to a specific group of recipients which varies in number. The code below works but there is a problem. When defining the strRecTo variable I have to set the number of instances and that has to be a constant. I've set this to 5 because that is the max no of people that i'll send to. If group 1 has 5 recipients they all get a mail. If group 2 then has only 2 recipients those two people get their mail but so does the 3rd 4th and 5th person of group 1 because strRecTo variable is still storing their address. Is there any way I can reset the variable so that doesn't store addresses from the previous group?
Thanks, Tom
Dim strRecTo(1, 5) As String
Set ToRecRst = dbs.OpenRecordset("SELECT tbl_Recipients.[E-mail], tbl_Recipients.CC, tbl_Recipients.TeamGroup FROM tbl_Recipients WHERE (((tbl_Recipients.CC)=0) AND ((tbl_Recipients.TeamGroup)='" & TeamRst.[TeamGroup] & "'));")
i = 0
While Not ToRecRst.EOF
strRecTo(0, i) = ToRecRst.[E-Mail]
i = i + 1
ToRecRst.MoveNext
Wend
Thanks, Tom
Dim strRecTo(1, 5) As String
Set ToRecRst = dbs.OpenRecordset("SELECT tbl_Recipients.[E-mail], tbl_Recipients.CC, tbl_Recipients.TeamGroup FROM tbl_Recipients WHERE (((tbl_Recipients.CC)=0) AND ((tbl_Recipients.TeamGroup)='" & TeamRst.[TeamGroup] & "'));")
i = 0
While Not ToRecRst.EOF
strRecTo(0, i) = ToRecRst.[E-Mail]
i = i + 1
ToRecRst.MoveNext
Wend