Solved

double click resulting in a click event

Posted on 1998-05-29
5
137 Views
Last Modified: 2010-05-03
I have a form with a listbox containing a list of contacts. Double clicking on a contact brings onother form with contact detail. The problem is that when the Contact details form has a button at the same mouse position it gets activated (Click event). This is a VB documented bug. Does anybody knows a stable way to prevent it?
0
Comment
Question by:tp
5 Comments
 

Expert Comment

by:nguy
ID: 1462048
tp
Well, if you have the SP3 and you're still having this problem you may have to call a MousUp from within the ListBox_DblCllick event procedure just to circumvent the Click Event.
0
 
LVL 3

Expert Comment

by:MorFF
ID: 1462049
nguy, I have tried this but without success.
You can easily simulate the situation with puting a big SSCommand1 button on Form2. On Form1_DblClick just show Form2.
It's suppose to be SSCommand button problem.
0
 

Author Comment

by:tp
ID: 1462050
You might want to try MorFF's suggestion by moving the position of the command button on the second form or disable the click event of command button and have it react only to double clicks.
0
 

Expert Comment

by:nguy
ID: 1462051
This is a problem that has plagued mankind since...

Well, to get to the meat of the matter, here is a solution that has worked for me.
Place a timer control on your form.  Set the timer's interval property to 100, set enabled property to False.
Add a module level variable to the declarations section:
Private m_bDblClick As Boolean

In your Listbox Click event place the following code:
Private Sub List1_Click()
  m_bDblClick = False
  Timer1.Enabled = True
End Sub

In the double click event, place the following code:
Private Sub List1_DblClick()
  m_bDblClick = True
End Sub

In the timer event of the timer control, place the following code:
Private Sub Timer1_Timer()
  If m_bDblClick Then
    Debug.Print "DblClick"
    'Or whatever double click code should happen
  Else
    Debug.Print "Click"
    'Or whatever click code should happen
  End If
  Timer1.Enabled = False
End Sub

Coding for more than one list box is possible, but has it's drawbacks, but for a single list box, this works well.
0
 
LVL 6

Accepted Solution

by:
clifABB earned 150 total points
ID: 1462052
tp

good solution from clifABB! (mine's a bit more straightforward tho!)
sorry nguy, have to disagree with you on the button doubleclick, makes it non standard windows functionality.

Cheers - MorFF
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question