Databases Reference
In-Depth Information
oRecordSet.MoveNext ' Move to next record in table.
Loop
Call CleanUpQuery
'Load from Listbox
Case False
'Copy over only SELECTED Items to Chosen Listbox
'Set Number of Columns
frm7Bind.ListBox_Chosen.ColumnCount =
frm7Bind.ListBox_All.ColumnCount
For index = 0 To frm7Bind.ListBox_All.ListCount - 1
'Check for Error Condition induced by indexes
If (index - DeletedItems) > frm7Bind.ListBox_All.ListCount
- 1 Then Exit For
If frm7Bind.ListBoxs_All.Selected(index - DeletedItems) = True Then
ListBox_Chosen.AddItem 'Add next row to list
'Track Items that have moved, 0 = not selected, else set
to position + 1
ReDim Preserve dBptr(index)
dBptr(index) = lbrow + 1
'This item is selected, add to Chosen ListBox
For col = 0 To frm7Bind.ListBox_All.ColumnCount - 1
'ListBox_All.AddItem oRecordSet.Fields(strDBField)
frm7Bind.ListBox_Chosen.List(lbrow, col) =
frm7Bind.ListBox_All.List(index - DeletedItems, col)
Next col
'Debug.Print index, lbrow, col,
frm7Bind.ListBox_Chosen.List(lbrow, 0),
frm7Bind.ListBox_All.List(index - DeletedItems, 0)
'Increment Listbox row
lbrow = lbrow + 1 'rows in listboxes begin @ 0!
'No () Here! frm7Bind.ListBox_All.RemoveItem (index - 1
- DeletedItems) = ERROR!
frm7Bind.ListBox_All.RemoveItem index - DeletedItems
DeletedItems = DeletedItems + 1
End If
Next index
End Select
End Sub
Some comments on the preceding subroutine. It will copy elements either directly from the
database or from the preexisting list box of database elements. Notice that elements are not copied
to the second list box unless they are checked (the selected property of the corresponding index of
the list box is set to TRUE). Most important, notice that both the list box and the database have
separate pointers to reference their data. This is imperative because the records in the database may
not necessarily have a one-to-one correspondence (indexwise) with the items present in the list
box. There will never be identical indexes between the database and list boxes if an element in the
Search WWH ::




Custom Search