![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm using an unbound multi select list box in an Access 2010 accdb. I want to apply a filter to the form so that it displays data for the currently selected row in the list box when I move from row to row in the list box using the down arrow key. (Note: I can do the same thing without a problem using the After Update event for the list box when a row is selected using the mouse, but I also want to provide the ability to use the keyboard only.) But when the arrow down keyboard key is used, the after update event doesn't trigger until after the focus moves to the next row, so that the form displays the data for the previously selected row. I've tried using the following in the KeyDown event for the list box: If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then MsgBox Me!lstLAN End If Before the event triggers, the list box has a non null value, and the arrow down does move to the next row. But the code generates a null value even though the focus has moved to the next row. I really don't understand why the afterupdate behaviour should be different for mouse clicking vs arrow down, but I would like to be enlightened. Does anyone have an alternative solution for what I'm trying to achieve. Bob Darlington Brisbane |
#3
| |||
| |||
|
|
"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in message news:4e2769c5$0$22474$afc38c87 (AT) news (DOT) optusnet.com.au... I'm using an unbound multi select list box in an Access 2010 accdb. I want to apply a filter to the form so that it displays data for the currently selected row in the list box when I move from row to row in the list box using the down arrow key. (Note: I can do the same thing without a problem using the After Update event for the list box when a row is selected using the mouse, but I also want to provide the ability to use the keyboard only.) But when the arrow down keyboard key is used, the after update event doesn't trigger until after the focus moves to the next row, so that the form displays the data for the previously selected row. I've tried using the following in the KeyDown event for the list box: If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then MsgBox Me!lstLAN End If Before the event triggers, the list box has a non null value, and the arrow down does move to the next row. But the code generates a null value even though the focus has moved to the next row. I really don't understand why the afterupdate behaviour should be different for mouse clicking vs arrow down, but I would like to be enlightened. Does anyone have an alternative solution for what I'm trying to achieve. Bob Darlington Brisbane A listbox's click event fires for each up or down navigation, so use that instead of afterupdate. HTH |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
You sure about "Before the event triggers, the list box has a non null value"? At least in previous versions of Access, a multi-select list box always returns a Null value, even if only a single item is selected. The only way to address its values was through its ItemsSelected collection. "Bob Darlington" wrote in message news:4e2769c5$0$22474$afc38c87 (AT) news (DOT) optusnet.com.au... I'm using an unbound multi select list box in an Access 2010 accdb. I want to apply a filter to the form so that it displays data for the currently selected row in the list box when I move from row to row in the list box using the down arrow key. (Note: I can do the same thing without a problem using the After Update event for the list box when a row is selected using the mouse, but I also want to provide the ability to use the keyboard only.) But when the arrow down keyboard key is used, the after update event doesn't trigger until after the focus moves to the next row, so that the form displays the data for the previously selected row. I've tried using the following in the KeyDown event for the list box: If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then MsgBox Me!lstLAN End If Before the event triggers, the list box has a non null value, and the arrow down does move to the next row. But the code generates a null value even though the focus has moved to the next row. I really don't understand why the afterupdate behaviour should be different for mouse clicking vs arrow down, but I would like to be enlightened. Does anyone have an alternative solution for what I'm trying to achieve. Bob Darlington Brisbane |
#6
| |||
| |||
|
|
I'm using an unbound multi select list box in an Access 2010 accdb. I want to apply a filter to the form so that it displays data for the currently selected row in the list box when I move from row to row in the list box using the down arrow key. (Note: I can do the same thing without a problem using the After Update event for the list box when a row is selected using the mouse, but I also want to provide the ability to use the keyboard only.) But when the arrow down keyboard key is used, the after update event doesn't trigger until after the focus moves to the next row, so that the form displays the data for the previously selected row. I've tried using the following in the KeyDown event for the list box: If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then MsgBox Me!lstLAN End If Before the event triggers, the list box has a non null value, and the arrow down does move to the next row. But the code generates a null value even though the focus has moved to the next row. I really don't understand why the afterupdate behaviour should be different for mouse clicking vs arrow down, but I would like to be enlightened. Does anyone have an alternative solution for what I'm trying to achieve. Bob Darlington Brisbane |
#7
| |||
| |||
|
|
I wasn't aware of the null value being returned by a multi select list box even with a single item is selected, so thanks for the info. I still don't understand why though. |
![]() |
| Thread Tools | |
| Display Modes | |
| |