ListBox Problem - 01-09-2012 , 08:18 PM
This is a follow up to previous unresolved thread which was getting a
I have a multi select (extended) unbound list box which has a problem
with the keypress event.
I'm using the following code in the Click event (which is the last event
to run after the KeyPress is triggered).
The Process_lst function applies a filter to the main form and returns
the position of the correct record in the list box every time for click,
keypress or keydown events (so that isn't a problem).
The rest of the code shown is only to test what is happening.
vIndex = Process_lst
For i = 0 To .ListCount - 1
If .Selected(i) = True Then MsgBox "Click " & i
For simplicity, assume the list box contains the following values with
the relevant list indices shown:
Value List Index
If I press "B", index 2 is selected and the correct filter is applied
to the form for B1.
If I then press "B" a second time (looking for the next value starting
with 'B'), row 3 is initially selected, the correct filter is applied
(for B2) but the List resets to index 2 (B1). So at this stage the list
and form are showing different records.
But the message box shows that the correct index (3) is selected every time.
My question is, what is happening after the click event to change the
value? And why does it only happen on the second call?
If I remove the Filter event from Process_lst, the behaviour doesn't
occur (but obviously I need the filter).
The records are not necessarily in alphabetic order as shown, hence the
need to search for the next value.
There is nothing in the main form which references the list box.
The Keypress and KeyDown events only sets a module variable for use by
the Process_lst function.
There is nothing in the Before or After Update events.
Hoping that someone can help.
Re: ListBox Problem - 01-10-2012 , 04:08 AM
On 10/01/2012 02:18:40, Bob Darlington wrote:
after the CurrentEvent on a form to the main key on the form. ie
Private Sub Form_Current()
lstcont = Me!ID
That way they always stay in sync.
Re: ListBox Problem - 01-12-2012 , 01:51 AM
On 10/01/2012 8:08 PM, Phil wrote: