D
Dale Fye
I've got a listbox (Multiselect = None) on a form (mdb database in Access
2007 with SP1).
When I right click on an item in the list, I popup a shortcut menu that
allows me to call a function that is supposed to open a report for the item
that I just "clicked" on. I'm using the MouseUp event to check for the
right button click. Unfortunately, it is not working the way I expected.
If I click (left button) on a list item, the lst_MouseUp event fires,
followed by the lst_Click event, and when I test the value of the list box,
it is correct. This is great. And if I follow this up with a RightClick, I
get the report for the correct item from the listbox.
However, if I RightClick on a previously unselected item from the list, and
run the report, I will normally get the report for the item that was last
"selected" via LeftClick. I had expected this might happen with the
MouseDown event, that's why I selected the MouseUp event.
When I added some breakpoints to my code, to see what was happening, things
got wierd. Although the Access help for the Listbox.Click event says that
"clicking a control with the right or middle mouse button does not trigger
this event", my code executes the Listbox.Click event, and does not execute
the MouseUp event. However, if I remove the breakpoints from the Click and
MouseUp events, then I get the following:
If I LeftClick an item, the Click event fires. If I follow that up with a
RightClick on the same list item, then the MouseUp event fires, and the
value of the list box is that of the item selected.
If I LeftClick an item, the Click event first. If I follow that up by
RightClicking on a different item, MouseUp event fires, and the value and
listindex of the listbox are the value and listindex associated with the
item that was selected via the previous LeftClick.
If I select an item via a RightClick, and then RightClick on another item,
then the value and listindex of the listbox will be the ones associated with
the most recent RightClick.
What I need is a foolproof way to ensure that no matter whether the user
LeftClicks, then RightClicks, or just RightClicks on a list item, the
"value" of the list will be that associated with the RightClick. I've tried
using the Listindex as well as checking to see whether the Selected property
of each of the list items could be used, but neither of these return the
guaranteed results I'm expecting.
Any ideas.
Dale
2007 with SP1).
When I right click on an item in the list, I popup a shortcut menu that
allows me to call a function that is supposed to open a report for the item
that I just "clicked" on. I'm using the MouseUp event to check for the
right button click. Unfortunately, it is not working the way I expected.
If I click (left button) on a list item, the lst_MouseUp event fires,
followed by the lst_Click event, and when I test the value of the list box,
it is correct. This is great. And if I follow this up with a RightClick, I
get the report for the correct item from the listbox.
However, if I RightClick on a previously unselected item from the list, and
run the report, I will normally get the report for the item that was last
"selected" via LeftClick. I had expected this might happen with the
MouseDown event, that's why I selected the MouseUp event.
When I added some breakpoints to my code, to see what was happening, things
got wierd. Although the Access help for the Listbox.Click event says that
"clicking a control with the right or middle mouse button does not trigger
this event", my code executes the Listbox.Click event, and does not execute
the MouseUp event. However, if I remove the breakpoints from the Click and
MouseUp events, then I get the following:
If I LeftClick an item, the Click event fires. If I follow that up with a
RightClick on the same list item, then the MouseUp event fires, and the
value of the list box is that of the item selected.
If I LeftClick an item, the Click event first. If I follow that up by
RightClicking on a different item, MouseUp event fires, and the value and
listindex of the listbox are the value and listindex associated with the
item that was selected via the previous LeftClick.
If I select an item via a RightClick, and then RightClick on another item,
then the value and listindex of the listbox will be the ones associated with
the most recent RightClick.
What I need is a foolproof way to ensure that no matter whether the user
LeftClicks, then RightClicks, or just RightClicks on a list item, the
"value" of the list will be that associated with the RightClick. I've tried
using the Listindex as well as checking to see whether the Selected property
of each of the list items could be used, but neither of these return the
guaranteed results I'm expecting.
Any ideas.
Dale