I've got a ListBox containing 10 items. When you left mouse click on any item, that item is highlighted and the listindex is set to that item that you clicked on. I need help doing the same action for a right mouse click.
Working with a listbox in Access while it has the focus is rather tricky when you are dealing with the selection stuff on the listbox. I know from having to deal with it in code cause you have the following issues, at least with the MultiSelect Property set to Extended:
The listbox doesn't have it's Selection properties set while it has the focus.
While the listbox has the focus, the True/False deal on the Selection property of each item does not work the same as how it's documented in the help file. Instead, the false (value of 0) does nothing to the selection of the item while the true (value of -1) changes the state of the selection on the item (Either from Selected to not selected or from not selected to selected).
Since these properties are not updated while the listbox retains the focus, you can't rely on these properties to show which items are selected and which items are not selected.
When the listbox gets the focus, every single item's selection property appears to be false, so this does not help matters either.
I have also found a rather wierd situation that I have documented as following:
SHIFT KEY DOESN’T SEEM TO BE WORKING WITH KEYBOARD METHOD
If you select multiple items via “Ctrl” key and the mouse, then hold down the Shift key and use either the up arrow or the down arrow, it will work once, but try it a second time in a row, it fails.
Even in one case in particular, it has caused the item to not highlight properly until you cause another form or application to come to the front of the screen and hide the form that the list box is on, which then when you bring the form back up that has the listbox on it, it then shows the items all selected as expected.
Steps to recreate this behavior
Create a test form
Add a Listbox to it
Set the RowSourceType as Value List
Set Multi Select to Extended
Set RowSource =
Test1;Test2;Test3;Test4;Test5;Test6;Test7;Test8;Test9;Test10;Test11;Test12
Set ColumnCount = 1
Now close out the Property dialog box, if you have it open.
Goto Form (Run-time) mode
Click and hold the Left mouse button down on "Test4" item
As holding down the left mouse button, drag the mouse to "Test7" item
Left up on the mouse left button
Press and hold the "Ctrl" key (either one, doesn't matter)
Now single click and left up with the left mouse button on "Test8" item
Lift up on the “Ctrl” key
Hold down the "Shift" key (either one, doesn't matter)
Press and release the "Up Arrow" key.
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.