[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

double click resulting in a click event

Posted on 1998-05-29
5
Medium Priority
?
154 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 300 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

834 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