开发者

Access 2003 VBA: Return only the index of the last item selected in a ListBox

I will preface this with saying, this is my first time using listboxes and earlier posts were criticized for lacking detail. So, all help is greatly appr开发者_JS百科eciated and I hope this is enough information without being overkill.

Currently, I have a listbox updating a junction table with an on click event (iterates through selected items and if they are not in the table it adds them). The list box is also updated by an option group (based on the option group value a query populates the list with the appropriate items and they are selected/highlighted based on the junction table). Also, when items are a "sub-category" the "category" is also selected. This functions perfectly until I ask it to do more...

Problem 1: I need to differentiate "categories" of items from each other. So, I have included a blank item to the list box to add a space between categories. When the blank items are present the listbox does not update the junction table properly and vice versa.

Problem 2: My users want to be able to deselect the "category" under certain circumstances. This is fine, just de-select the "category" after the "sub-category" is selected. However, the "category" is re-selected whenever the listbox is clicked again because it iterates through all entries.

Perceived solution for both problems: Return only the index of the item (de)selected and manipulate accordingly. Is this possible? If so, how?

OR: Should I take a different approach?


One can think of a list or combo box as a low-resource sub-form. Conversely, one can use a sub-form to take care functions usually handled with a list or combo box.

I don't understand all that you're trying to do, but I do know that "up-sizing" to a sub-form is usually the answer when a simple control (for whatever reason) can't cover the need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜