Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to write all values or append to list

Status
Not open for further replies.

Sammy145

Programmer
Oct 4, 2002
173
0
0
GB
What i am doing or need to do is get a list of names from a table and add it to a notes email
i only want the list in one email so i tried to loop around the table and get the values BUT it only sends one name (IN THE VARIABLE COUNTERS)

Can someone SHOW me how to do this ??

Dim Rs
Dim COUNTERS
''Connection object is here
Set Rs = CreateObject("ADODB.Recordset")
sSQL2 = "Select USER_GROUP_NM from USER_GROUP_DELETED"
Set Rs = ObjConn.Execute(sSQL2)

While Not Rs.EOF Or Rs.bof
COUNTERS = Rs.fields("USER_GROUP_NM")
Rs.movenext
Wend

strMessage = "There is an error in the DTS package " & Counters


Thanks in advance

 
change your code to the following

While Not Rs.EOF Or Rs.bof
COUNTERS = Counters & Rs.fields("USER_GROUP_NM")
Rs.movenext
Wend
 
hi there im a bit confused
the result i want to see in strMessage is

strMessage = "There is an error in the DTS package check " A,B
A comma betweeen each Counters or space

so when i get 1 email
it will say in the message
"There is an error in the DTS package check" A,B

Thanks in advance
 
your statement:

COUNTERS = Rs.fields("USER_GROUP_NM")

is only assigning the current value from the recordset into the variable counters. In order to append the names to the list, you'll need to append them together, keeping the existing value of COUNTERS.

Inside the loop, the assignment statement should read as follows:

COUNTERS = COUNTERS & Trim(Rs.fields("USER_GROUP_NM")) & ","

Once you exit the loop, you need to remove the comma at the end

COUNTERS = Left(COUNTERS, Len(COUNTERS) - 1)

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top