Hi
I am trying to filter a table of users to select only those records
whose roleID matches a value in an array. There could be any number of
IDs held in the array from one to a few hundred. The array is
generated by splitting a comma delimited memo field from a second
table in an Access DB. I can split the memo field OK, I can
response.write its values, but what I now want to do is add a value
from another table to my reponse write loop.
ie. memo field might contain IDs 1, 2, 4
This splits into array
1
2
4
And I want to match up with contents in the non-autonumber field of a
table wchich might look something like:
tblRoles
RoleID(autonumb er field), emailaddress
1, a@address.com
2, b@address.com
3, c@address.com
4, d@address.com
Such that what appears on my output page is:
a@address.com
b@address.com
d@address.com
i.e. no c because 3 is not in the array.
Full code of page so far:
<%@LANGUAGE="VB SCRIPT" CODEPAGE="1252" %>
<!--#include file="../Connections/connMomentaDB.a sp" -->
<%
Dim rsLastList__MMC olParam
rsLastList__MMC olParam = "1"
If (Session("LastL ist") <> "") Then
rsLastList__MMC olParam = Session("LastLi st")
End If
%>
<%
Dim rsLastList
Dim rsLastList_numR ows
Set rsLastList = Server.CreateOb ject("ADODB.Rec ordset")
rsLastList.Acti veConnection = MM_connMomentaD B_STRING
rsLastList.Sour ce = "SELECT ListID, MailingList FROM tblxCampPers
WHERE ListID = " + Replace(rsLastL ist__MMColParam , "'", "''") + ""
rsLastList.Curs orType = 0
rsLastList.Curs orLocation = 2
rsLastList.Lock Type = 1
rsLastList.Open ()
rsLastList_numR ows = 0
%>
<% varMailingList = split(rsLastLis t("MailingList" ), ", ", -1, 1 ) %>
<%
Dim rsRoles
Dim rsRoles_numRows
Set rsRoles = Server.CreateOb ject("ADODB.Rec ordset")
rsRoles.ActiveC onnection = MM_connMomentaD B_STRING
rsRoles.Source = "SELECT RoleID, emailadd FROM tblRoles"
rsRoles.CursorT ype = 0
rsRoles.CursorL ocation = 2
rsRoles.LockTyp e = 1
rsRoles.Open()
rsRoles_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitl ed Document</title>
</head>
<body>
<p>Your mailing list has been created and is list number
<%=(rsLastList. Fields.Item("Li stID").Value)%>
</p>
<p>
' The section below currently writes the roleID, but I want it to
write the email address instead
<% for myCounter=0 to ubound(varMaili ngList)
response.write varMailingList( myCounter) & "<BR>" & vbcrlf
next
%>
</p>
<p> </p>
</body>
</html>
<%
rsLastList.Clos e()
Set rsLastList = Nothing
%>
<%
rsRoles.Close()
Set rsRoles = Nothing
%>
I presume I need a second loop within the varMailingList loop which
returns the matching record in rsRoles?
Any help gratefully received!
Thanks in advance
TimP