|
-
Apr 12th, 2004, 02:54 PM
#1
Thread Starter
Addicted Member
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:
Dim strId As Collection, strX As String
Set strId = New Collection
strX = "1"
x = 1
Do Until rcdTable2.EOF
strId.Add rcdTable2(0), strX
x = x + 1
strX = x
rcdTable2.MoveNext
Loop
intX = Int(strX)
rcdTable2.Close
Do Until rcdTable1.EOF
strInsert = nonulls(rcdTable1(0))
On Error Resume Next
strId.Item (strInsert)
If Err.Number = 0 Then
Set lsiItem = frmMain.lsvEnrollHorse.ListItems.Add(, , strInsert)
For k = 1 To 14
strInsert = nonulls(rcdTable1(k))
lsiItem.ListSubItems.Add , , strInsert
Next k
End If
rcdTable1.MoveNext
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....
-
Apr 12th, 2004, 09:03 PM
#2
strId.Item (strInsert) or just strId(strInsert) is correct syntactically but it is meant to return something, so you need to do something like MsgBox strId.Item(strInsert) where you use the returned value. I know that in your case you don't want to use MsgBox but I can't figure out what it that you want to do with the value from the collection.
-
Apr 12th, 2004, 11:24 PM
#3
Thread Starter
Addicted Member
Basically, if that ID number is found in the table holding all the registered horses, then it lets its data be inserted into the listview box.
if the horse is not found, then it skips it and goes on to the next horse found in the Horses Table.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|