Results 1 to 3 of 3

Thread: collection comparison not working...

Threaded View

  1. #1

    Thread Starter
    Addicted Member myrrdan's Avatar
    Join Date
    Nov 2002
    Location
    Alberta Canada
    Posts
    202

    collection comparison not working...

    I have 2 tables, the one holds all data for the horses that have been enrolled in an incentive program.
    The other holds data for every horse.
    Now I have them both opened, but only the horses that are in the first table can be selected, so i only want those inserted into a listview box...
    This is the code i have so far.

    VB Code:
    1. Dim strId As Collection, strX As String
    2.     Set strId = New Collection
    3.     strX = "1"
    4.     x = 1
    5.     Do Until rcdTable2.EOF
    6.         strId.Add rcdTable2(0), strX
    7.         x = x + 1
    8.         strX = x
    9.         rcdTable2.MoveNext
    10.     Loop
    11.     intX = Int(strX)
    12.     rcdTable2.Close
    13.     Do Until rcdTable1.EOF
    14.         strInsert = nonulls(rcdTable1(0))
    15.         On Error Resume Next
    16.         strId.Item (strInsert)
    17.         If Err.Number = 0 Then
    18.             Set lsiItem = frmMain.lsvEnrollHorse.ListItems.Add(, , strInsert)
    19.             For k = 1 To 14
    20.                 strInsert = nonulls(rcdTable1(k))
    21.                 lsiItem.ListSubItems.Add , , strInsert
    22.             Next k
    23.         End If
    24.     rcdTable1.MoveNext
    25.     Loop

    now the problem is this..

    if i dont' enter any number at all, it grabs all the records in the first table, holding all those enrolled in the incentive program.
    But when it loops through the other table holding all horse info, it only finds a dozen or so numbers.. where there is 270+ in the incentive program, and 500+ horses.
    So what am I doing wrong?

    I think that the comparison i'm using the wrong syntax.

    --> strId.Item (strInsert)

    now strInsert is the index of the item, but i need to check every item.. do i have to do a for z to strId.Count loop???
    Last edited by myrrdan; Apr 12th, 2004 at 02:59 PM.
    Oooops.....theres another semi-colon in the wrong spot....

Posting Permissions

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



Click Here to Expand Forum to Full Width