Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single Click / Double Click - Command Buttons

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
A real simple question. I have set my double click speed as low as it will go on my mouse. I have some reports where I do a report preview for single click, and output to an excel file on double click.

The single click option is overriding the double click option. Is there an antidote for this, or is it not possible to have programs work this way?

Thanks in advance for any answers.

 
Unfortunately Access does not differentiate between a double-click and a single-click; It will always raise the single-click event before the double-click, effectively running both on a double-click. Any double-click action will append to the single-click action.

My suggestion is to create a second button.

A very complicated option would be to only use the OnClick event and test for the single and double-click yourself. When the button is clicked, it checks the current tick with a stored tick number and sees if they are sufficiently close (in essence a double-click). If they are not it turns on the form timer and sets the timer value to a low number, the next time the OnTimer runs you can run the Single-Click event because the button was not clicked soon enough again for a double-click. If the button is pressed twice sufficiently fast enough it should turn off the form timer so that the singl-click code never runs. Like I said, very complicated and good chance of not running correctly. Go with two buttons.

Hope this helps,
Tom
 
You can use a workaround, which utilizes the Form_Timer() event, if you're not already using the timer for something else on that form. Here's a sample:
Code:
Option Compare Database
Option Explicit

Private mblnDoubleClicked As Boolean

Private Sub cmdClicks_Click()
  Me.TimerInterval = 200     [green]'turn on timer[/green]
End Sub

Private Sub cmdClicks_DblClick(Cancel As Integer)
  mblnDoubleClicked = True   [green]'set flag[/green]
End Sub

Private Sub Form_Timer()
  Me.TimerInterval = 0       [green]'turn off timer[/green]
  
  If mblnDoubleClicked Then
    mblnDoubleClicked = False  [green]'reset flag[/green]
    MsgBox "Double Clicked"
    [green]'run 2-click code...[/green]
  Else
    MsgBox "Single Clicked"
    [green]'run 1-click code...[/green]
  End If  
End Sub

Remove the MsgBox calls after you prove it works...

VBSlammer
redinvader3walking.gif

[sleeping]Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top