ListBox Problem

TheSearcher

Registered User.
Local time
Today, 10:09
Joined
Jul 21, 2011
Messages
392
I have a listbox in which I am using both the single and double click events to return different data. It seems that when I try to double-click it is interpreted as a single click! It doesn't seem to "wait" for the second click. I have been coding for years but never saw this before. Does anyone know why this is happening??

Thanks,
TS:confused:
 
I just did a quick test with a simple form with a single command button on it. I added two events to the command button, a single click and a double click:

Option Compare Database
Option Explicit

Private Sub Command0_Click()
MsgBox " Single Click"
End Sub

Private Sub Command0_DblClick(Cancel As Integer)
MsgBox " Double Click"
End Sub

The single click returned the message single click and the double click returned the message double click.

however only the single click responded, this would indicate that the single click is intercepting the key presses and negotiating the double click.

I double checked that the events were working independently by commenting them out individually:

'Private Sub Command0_Click()
' MsgBox " Single Click"
'End Sub
 
From Access Help:
The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

Double-clicking a control causes both Click and DblClick events to occur. If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.
 
More from Access Help
For objects that receive mouse events, the events occur in this order:

MouseDown → MouseUp → Click → DblClick

When you double-click a command button , the following events occur in this order:

MouseDown → MouseUp → Click → DblClick → MouseUp → Click

The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event). To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure. Note that, generally speaking, double-clicking a command button should be discouraged.
 
Thank you for responding! I'm having the problem in a list box - not a command button but the pricipal, I'm sure, is the same. My work around was to use a keypress event in place of the single click. The strange thing is that I've been coding for 15 years and never saw this before! A most interesting line in your post was "within the double-click time limit of the system." I wonder where I would find that!
Thanks for all the info.
TS
 
This was written in Access97 under Windows 2000 and still works in Access2003 under XP.

But "The Times they are a changin."

Chris.
 

Attachments

Users who are viewing this thread

Back
Top Bottom