A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

List Box Click Event Anomaly.



 
 
Thread Tools Display Modes
  #11  
Old March 10th, 2010, 08:07 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default List Box Click Event Anomaly.

"Peter Hibbs" wrote in message
...

Thanks for the idea, your idea did not work


What was wrong, if you don't mind my asking? I can't see why it wouldn't
work, if implemented correctly.

but I have found a
solution using a similar method but the other way round.


Regardless, I'm glad you found a solution.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #12  
Old March 10th, 2010, 11:12 PM posted to microsoft.public.access.forms
Peter Hibbs
external usenet poster
 
Posts: 871
Default List Box Click Event Anomaly.

Dirk,

It could be that "implemented correctly" is the relevant part but I
used this logic with the code below. When the mouse is down the vCheck
flag is Set and when the mouse is released the vCheck flag is reset.

When the list box gets the focus (with the TAB key) and the arrow keys
are then pressed, the vCheck flag will be False and so the Click event
will be triggered but is be ignored, i.e. the routine will exit
immediately. And this works OK, the arrow keys move the cursor up and
down the list of entries.

My idea was that when the user actually clicked on a list box entry,
the vCheck flag would be set True and so the Click event code would
then execute. But it doesn't happen, it seems the flag is still False
when the Click event triggers and the code just exits the routine.


Private Sub lstClients_Click()

If vCheck = False Then Exit Sub
'...code here....

End Sub

Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
vCheck = True
End Sub

Private Sub lstClients_MouseUp(Button As Integer, Shift As Integer, X
As Single, Y As Single)
vCheck = False
End Sub

If you have some alternative code I would be interested to see it
although, as I said, my code does work.

Peter Hibbs.



On Wed, 10 Mar 2010 15:07:13 -0500, "Dirk Goldgar"
wrote:

"Peter Hibbs" wrote in message
.. .

Thanks for the idea, your idea did not work


What was wrong, if you don't mind my asking? I can't see why it wouldn't
work, if implemented correctly.

but I have found a
solution using a similar method but the other way round.


Regardless, I'm glad you found a solution.

  #13  
Old March 11th, 2010, 07:13 AM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default List Box Click Event Anomaly.

"Peter Hibbs" wrote in message
...
Dirk,

It could be that "implemented correctly" is the relevant part but I
used this logic with the code below. When the mouse is down the vCheck
flag is Set and when the mouse is released the vCheck flag is reset.

When the list box gets the focus (with the TAB key) and the arrow keys
are then pressed, the vCheck flag will be False and so the Click event
will be triggered but is be ignored, i.e. the routine will exit
immediately. And this works OK, the arrow keys move the cursor up and
down the list of entries.

My idea was that when the user actually clicked on a list box entry,
the vCheck flag would be set True and so the Click event code would
then execute. But it doesn't happen, it seems the flag is still False
when the Click event triggers and the code just exits the routine.


Private Sub lstClients_Click()

If vCheck = False Then Exit Sub
'...code here....

End Sub

Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
vCheck = True
End Sub

Private Sub lstClients_MouseUp(Button As Integer, Shift As Integer, X
As Single, Y As Single)
vCheck = False
End Sub

If you have some alternative code I would be interested to see it
although, as I said, my code does work.



The sequence of events for a mouse click on a control is:

MouseDown - MouseUp - Click

So your code, which resets vCheck in the MouseUp event, will result in
vCheck always being False in the Click event. You should reset vCheck in
the Click event instead:

'------ start of revised code ------
' Declared at module level
Dim vCheck As Boolean

Private Sub lstClients_Click()

If vCheck = False Then Exit Sub

vCheck = False

'...code here....

End Sub

Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
vCheck = True
End Sub

'*** NO lstClients_MouseUp EVENT PROCEDURE ***
'------ end of revised code ------


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #14  
Old March 11th, 2010, 11:13 AM posted to microsoft.public.access.forms
Peter Hibbs
external usenet poster
 
Posts: 871
Default List Box Click Event Anomaly.

Dirk,

Yes, that works fine. I will use your solution, I think, as it is
slightly simpler than mine.

Thanks again.

Peter Hibbs.

On Thu, 11 Mar 2010 02:13:44 -0500, "Dirk Goldgar"
wrote:

"Peter Hibbs" wrote in message
.. .
Dirk,

It could be that "implemented correctly" is the relevant part but I
used this logic with the code below. When the mouse is down the vCheck
flag is Set and when the mouse is released the vCheck flag is reset.

When the list box gets the focus (with the TAB key) and the arrow keys
are then pressed, the vCheck flag will be False and so the Click event
will be triggered but is be ignored, i.e. the routine will exit
immediately. And this works OK, the arrow keys move the cursor up and
down the list of entries.

My idea was that when the user actually clicked on a list box entry,
the vCheck flag would be set True and so the Click event code would
then execute. But it doesn't happen, it seems the flag is still False
when the Click event triggers and the code just exits the routine.


Private Sub lstClients_Click()

If vCheck = False Then Exit Sub
'...code here....

End Sub

Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
vCheck = True
End Sub

Private Sub lstClients_MouseUp(Button As Integer, Shift As Integer, X
As Single, Y As Single)
vCheck = False
End Sub

If you have some alternative code I would be interested to see it
although, as I said, my code does work.



The sequence of events for a mouse click on a control is:

MouseDown - MouseUp - Click

So your code, which resets vCheck in the MouseUp event, will result in
vCheck always being False in the Click event. You should reset vCheck in
the Click event instead:

'------ start of revised code ------
' Declared at module level
Dim vCheck As Boolean

Private Sub lstClients_Click()

If vCheck = False Then Exit Sub

vCheck = False

'...code here....

End Sub

Private Sub lstClients_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
vCheck = True
End Sub

'*** NO lstClients_MouseUp EVENT PROCEDURE ***
'------ end of revised code ------

 




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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.