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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a record from a GetRows() array

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
If I have the following, is there any way of displaying the information in the Secretaries() array while looping through a recordset. EG If the UserID value in the array matches the rs("SecretaryID") value then display the details (firstname, surname, extension) of the secretary?

<%
rs.Open "SELECT UserID, FirstName, Surname, Extension FROM Users WHERE Secretary=TRUE", DB
Secretaries=rs.GetRows()
rs.Close
%>

Then

<table>
<%
rs.Open "SELECT UserID, FirstName, Surname, Extension, SecretaryID FROM Users WHERE Lawyer=TRUE", DB
Do While Not rs.EOF
%>
<tr>
<td><% = rs("FirstName") %></td>
<td><% = rs("Surname") %></td>
<td><% = Extension") %></td>
</tr>
<%
rs.MoveNext
Loop
rs.Close
%>
</table>
 
emozley,

Yes there is. Forgive me if this isn't 100% accurate, but this will get you going if it's not perfect. Secretaries is a multidimensional array after using GetRows(). What I would do is add a small for loop inside your while loop, like so:

Code:
<%
rs.Open "SELECT UserID, FirstName, Surname, Extension FROM Users WHERE Secretary=TRUE", DB
Secretaries=rs.GetRows()
rs.Close
%>

Then

<table>
<%
rs.Open "SELECT UserID, FirstName, Surname, Extension, SecretaryID FROM Users WHERE Lawyer=TRUE", DB
Do While Not rs.EOF
%>
<tr>
<td><% = rs("FirstName") %></td>
<td><% = rs("Surname") %></td>
<td><% = Extension") %></td>
</tr>
<%
[b]
for i=0 to UBound(Secretaries,2)
   if rs("SecretaryID")=Secretaries(i,0) then
      'Put your secretary display code here
      exit for
   end if
next
[/b]
rs.MoveNext
Loop
rs.Close
%>
</table>

Multidimensional arrays can be difficult to wrap your head around sometimes, I try to think them out pretty thoroughly. Do this work for you?

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top