Resetting A Variable

TKnight

Registered User.
Local time
Today, 21:19
Joined
Jan 28, 2003
Messages
181
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
 
  1. Dim strRecTo(1, 5) gives an array with 2 dimensions.
  2. To clear an array: ReDim strRecTo(1 To 5)
    [/list=1]
 
Last edited:
Thanks mate, the code that I got it from has a sender name as well as address so i'm assuming thats where the second dimention in the array comes from. I'll clear it.
Thanks for your help....
With the amount of e-mails my DB just sent out i expect i'll get a call from the MyDoom investigation team!!!


:D
 
Mile-o-Phile
I just tried that and it threw up an error message saying that the array was already defined. Help says that you can only ReDim a dynamic array .

I tried making it dynamic by substituting the
Dim strRecTo(1 To 5)

with
Dim strRecTo(n)

so that I could reset it later on but the debugger said that the array had to contain a constant value. Is there any way I can get round the problem?
Thanks, Tom.
 
Sorry, forgot that:

This basic structure can also clear the array.

Code:
For i = 1 To 5
    MyArray(i) = vbNullString
Next
 
Thanks a lot mate that seems to have sorted it.....
Tom
 

Users who are viewing this thread

Back
Top Bottom