Array Question

1. Senior Member
Join Date
Dec 1969
Posts
330

## Array Question

I&#039;m having trouble figuring out this array that a co-worker (that is out the rest of the week) wrote. Could anyone help?<BR><BR>First I have this query:<BR><BR>SQLCorp = "Select a.name as tklast,a.emplid as udvalue,b.tkid as tkid from " & _<BR> "corporate..person_tbl a,corporate..tk_emp_map_tbl b where a.emplid=b.emplid " & _<BR> "and a.job_code in (select job_code from corporate..jobs_attorney_map_tbl " &_<BR> "where a.job_code &#060;&#062; &#039;00128&#039; and status in (&#039;A&#039;,&#039;L&#039;,&#039;P&#039;)) " & _<BR> "order by a.name"<BR><BR>Set oRsAtty = connCorp.Execute(SQLCorp)<BR><BR><BR><BR>Then the array<BR><BR>&#039; Build the array that holds the attorney names<BR> intNumAtty = oRsAtty.RecordCount - 1<BR> Dim myArray(2000,2)<BR> x = 0<BR> Do<BR> myArray(x,0) = oRsAtty("tklast")<BR> myArray(x,1) = oRsAtty("udvalue")<BR> oRsAtty.MoveNext<BR> x = x+1<BR> Loop While not oRsAtty.EOF<BR><BR>then i have this sub which is part of a select box<BR><BR>&#060;%<BR> Sub ChooseAttorneys<BR> &#039; Build array to populate select box with data from corporate db<BR> AttyCount=0<BR> For y=0 to (x-1)<BR> AttyCount=AttyCount+1<BR> %&#062;<BR> &#060;!-- this next line is the actual line that is displayed each<BR> time an attorney name is listed. --&#062;<BR> &#060;option value="&#060;%=myArray(y,1)%&#062;"&#062;&#060;%=o RsAtty("tkid")%&#062;&nbsp;-&nbsp;&#060;%=myArray(y,0)%&#062;&#060;/option&#062;<BR> &#060;%<BR> Next<BR> &#039;Response.Write "Count=" & AttyCount<BR> End Sub<BR><BR> %&#062;<BR><BR><BR>What i want to do is add one more value, the tkid. Anyone know what to do. I don&#039;t understand the array too well. <BR><BR>Thanks

2. Senior Member
Join Date
Dec 1969
Posts
11,334

from your other guy. When he gets back, ask him if he ever heard of getRows(). He&#039;s doing everything manually.<BR><BR>&#062;What i want to do is add one more value, the tkid<BR><BR>Where? In your query? To the select box? What is &#039;tkid&#039;?

3. Senior Member
Join Date
Dec 1969
Posts
330

## RE: That's pretty bad code

The tkid is a value retrieved in the SQL query. I want to add it to the select box option tag so it appears something like the following:<BR><BR>&#060;option value="&#060;%=myArray(y,1)%&#062;"&#062;&#060;%=m yArray(y,2)%&#062;&nbsp;-&nbsp;&#060;%=myArray(y,0)%&#062;&#060;/option&#062;<BR><BR><BR>something like that

4. Senior Member
Join Date
Dec 1969
Posts
2,854

## you need to

worry only about this section..<BR><BR><BR> Dim myArray(2000,2) <BR> x = 0 <BR> Do <BR> myArray(x,0) = oRsAtty("tklast") <BR> myArray(x,1) = oRsAtty("udvalue") <BR><BR><BR>change it to....<BR><BR> Dim myArray(2000,3) <BR> x = 0 <BR> Do <BR> myArray(x,0) = oRsAtty("tklast") <BR> myArray(x,1) = oRsAtty("udvalue") <BR> myArray(x,2) = oRsAtty("tkid") <BR><BR>then, on this line<BR><BR>&#060;option value="&#060;%=myArray(y,1)%&#062;"&#062;&#060;%=o RsAtty("tkid")%&#062; - &#060;%=myArray(y,0)%&#062;&#060;/option&#062;<BR><BR>it should become......<BR><BR>&#060;option value="&#060;%=myArray(y,1)%&#062;"&#062;&#060;%=m yArray(y,2)%&#062; - &#060;%=myArray(y,0)%&#062;&#060;/option&#062;<BR><BR>or something like that

5. Senior Member
Join Date
Dec 1969
Posts
101

## RE: Array Question

This is quite ugly.. but here is how you add the tkid<BR><BR>&#039; Build the array that holds the attorney names<BR>intNumAtty = oRsAtty.RecordCount - 1<BR>Dim myArray(2000,3)<BR>x = 0<BR>Do<BR>myArray(x,0) = oRsAtty("tklast")<BR>myArray(x,1) = oRsAtty("udvalue")<BR>myArray(x,2) = oRsAtty("tkid")<BR>oRsAtty.MoveNext<BR>x = x+1<BR>Loop While not oRsAtty.EOF<BR><BR>... Some Code ...<BR><BR>&#060;option value="&#060;%=myArray(y,1)%&#062;"&#062;&#060;%=m yArray(y,2)%&#062; - &#060;%=myArray(y,0)%&#062;&#060;/option&#062;

6. Senior Member
Join Date
Dec 1969
Posts
1,024

## RE: Array Question

I think what you want is:<BR><BR> Build the array that holds the attorney names<BR>intNumAtty = oRsAtty.RecordCount - 1<BR>Dim myArray(2000,2)<BR>x = 0<BR>Do<BR>myArray(x,0) = oRsAtty("tklast")<BR>myArray(x,1) = oRsAtty("udvalue")<BR>myArray(x,2) = oRsAtty("tkid")<BR>oRsAtty.MoveNext<BR>x = x+1<BR>Loop While not oRsAtty.EOF<BR><BR>&#039;--------------------------<BR>AND THEN IN YOUR CHECKBOX<BR>&#039;------------------------<BR><BR>&#060;option value="&#060;%=myArray(y,1)%&#062;"&#062;&#060;%=m yArray(y,2)%&#062; - &#060;%=myArray(y,0)%&#062;&#060;/option&#062;<BR><BR><BR>????<BR><BR>Does that help?<BR><BR>CP<BR><BR>He&#039;s just build a 2-d array, with row 0 being the &#039;tklast&#039; and row 1 the &#039;udvalue&#039;.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•