B
BobRoyAce
I have a table of categories where I pull a category name (RS.Fields(0)) and
a field that indicates whether that category should be included
RS.Fields(1). Then, I try to populate a list box, who's Multiselect property
is set to Extended, placing all categories into it and selecting the ones
for which the Include field value is TRUE. When the code shown below is run,
the list box is populated with all categories, but only the last one is
actually selected (even though, in this case, all of them should be
selected). What am I doing wrong here?
--- CODE BEGINS ---
iCategoryCount = 0
DoEvents
If Not RS.EOF Then
lstCategories.RowSource = """" & RS.Fields(0) & """"
lstCategories.Selected(iCategoryCount) = RS.Fields(1)
iCategoryCount = 1
RS.MoveNext
End If
While Not RS.EOF
lstCategories.RowSource = lstCategories.RowSource & ";""" &
RS.Fields(0) & """"
lstCategories.Selected(iCategoryCount) = RS.Fields(1)
iCategoryCount = iCategoryCount + 1
RS.MoveNext
Wend
DoEvents
--- CODE ENDS ---
a field that indicates whether that category should be included
RS.Fields(1). Then, I try to populate a list box, who's Multiselect property
is set to Extended, placing all categories into it and selecting the ones
for which the Include field value is TRUE. When the code shown below is run,
the list box is populated with all categories, but only the last one is
actually selected (even though, in this case, all of them should be
selected). What am I doing wrong here?
--- CODE BEGINS ---
iCategoryCount = 0
DoEvents
If Not RS.EOF Then
lstCategories.RowSource = """" & RS.Fields(0) & """"
lstCategories.Selected(iCategoryCount) = RS.Fields(1)
iCategoryCount = 1
RS.MoveNext
End If
While Not RS.EOF
lstCategories.RowSource = lstCategories.RowSource & ";""" &
RS.Fields(0) & """"
lstCategories.Selected(iCategoryCount) = RS.Fields(1)
iCategoryCount = iCategoryCount + 1
RS.MoveNext
Wend
DoEvents
--- CODE ENDS ---