dbTalk Databases Forums  

ListBox Problem

comp.databases.ms-access comp.databases.ms-access


Discuss ListBox Problem in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default ListBox Problem - 01-09-2012 , 08:18 PM






This is a follow up to previous unresolved thread which was getting a
bit messy.

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
With Me!lstCont
For i = 0 To .ListCount - 1
If .Selected(i) = True Then MsgBox "Click " & i
Next
End With

For simplicity, assume the list box contains the following values with
the relevant list indices shown:
Value List Index
A1 0
A2 1
B1 2
B2 3
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?

Notes:
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.

--
Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Phil
 
Posts: n/a

Default Re: ListBox Problem - 01-10-2012 , 04:08 AM






On 10/01/2012 02:18:40, Bob Darlington wrote:
Quote:
This is a follow up to previous unresolved thread which was getting a
bit messy.

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
With Me!lstCont
For i = 0 To .ListCount - 1
If .Selected(i) = True Then MsgBox "Click " & i
Next
End With

For simplicity, assume the list box contains the following values with
the relevant list indices shown:
Value List Index
A1 0
A2 1
B1 2
B2 3
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?

Notes:
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.

Don't know why you have the problem, but I always reset a ListBox or ComboBox
after the CurrentEvent on a form to the main key on the form. ie

Private Sub Form_Current()
lstcont = Me!ID
end sub

That way they always stay in sync.
Phil
Phil

Reply With Quote
  #3  
Old   
Bob Darlington
 
Posts: n/a

Default Re: ListBox Problem - 01-12-2012 , 01:51 AM



On 10/01/2012 8:08 PM, Phil wrote:
Quote:
On 10/01/2012 02:18:40, Bob Darlington wrote:
This is a follow up to previous unresolved thread which was getting a
bit messy.

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
With Me!lstCont
For i = 0 To .ListCount - 1
If .Selected(i) = True Then MsgBox "Click "& i
Next
End With

For simplicity, assume the list box contains the following values with
the relevant list indices shown:
Value List Index
A1 0
A2 1
B1 2
B2 3
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?

Notes:
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.


Don't know why you have the problem, but I always reset a ListBox or ComboBox
after the CurrentEvent on a form to the main key on the form. ie

Private Sub Form_Current()
lstcont = Me!ID
end sub

That way they always stay in sync.
Phil
Phil
Thanks Phil,
That seems to have solved that problem (very simply).


--
Bob Darlington
Brisbane

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.