Command button not responding to double click

John Sh

Member
Local time
Tomorrow, 01:48
Joined
Feb 8, 2021
Messages
540
I have a series of command buttons, set up with the code below , to index a column ascending with a single click or descending with a double click.
Using command buttons allows me to change the colour of the active button and enhance the form's appearance.
Problem is the command buttons are only responding to the first click.
If I use a label instead of the button then single and double clicks do their jobs but with the down side of looking flat and the colour change becomes a bit more complicated.
Is there an option to turn off / on the double click event?

Code:
Private Sub btnSpec_Raw_Click()
    setIndex "Spec_raw"
End Sub

Private Sub btnSpec_Raw_DblClick(Cancel As Integer)
    setIndex "Spec_raw Desc"
End Sub

Private Sub setIndex(str As String)
    Me.OrderBy = str
End Sub
 
Can't test it right now, but as soon as you click on a button, the click event fires. Since when you double-click, you're essentially clicking on that button, the click event fires. Depending on how fast you double-click, I think you will either just get the click event or maybe both. One workaround is to just use the click event and simple perform the ascending or descending order via a logic test, if possible.
 
Can't test it right now, but as soon as you click on a button, the click event fires. Since when you double-click, you're essentially clicking on that button, the click event fires. Depending on how fast you double-click, I think you will either just get the click event or maybe both. One workaround is to just use the click event and simple perform the ascending or descending order via a logic test, if possible.
I'll have a look at that, it's a good idea.
Funny that the double click works ok on the labels and on text boxes.
Thank you.
John
 
I would use a CheckBox, like...
Code:
Private Sub chkIsDesc_Click()
    setIndex
End Sub

Private Sub setIndex()
    Me.OrderBy = "Spec_raw" & IIf(Me.chkIsDesc, " Desc", "")
End Sub
I think a double-click on a command button is an unexpected behaviour.
 
There is also a Windows setting that is relevant. On Win 11 it is Start >> Settings >> Bluetooth >> Mouse >> Additional Mouse Settings, where you get to use a slider to control the sensitivity of a double-click. If the sensitivity is not fast enough, a double click responds as two single clicks. On earlier Win versions, it will be somewhere in Settings >> Devices and then diddle around with mouse options.
 
I would use a CheckBox, like...
Code:
Private Sub chkIsDesc_Click()
    setIndex
End Sub

Private Sub setIndex()
    Me.OrderBy = "Spec_raw" & IIf(Me.chkIsDesc, " Desc", "")
End Sub
I think a double-click on a command button is an unexpected behaviour.
Not a bad idea but I have 13 columns that need to be individually indexed ascending or descending depending on requirements.
Any column can be indexed and it controls what happens in the other columns so it's not as simple as a checkbox as I would need one for each column.
I'll continue to search for a way to determine the index order but for the time being I'll revert to labels as they do respond to double clicks.
One has to wonder why there is a doubleclick event listed for command buttons if it doesn't work or is that Access being consistently inconsistent?
Thank you for the response.
John
 
There is also a Windows setting that is relevant. On Win 11 it is Start >> Settings >> Bluetooth >> Mouse >> Additional Mouse Settings, where you get to use a slider to control the sensitivity of a double-click. If the sensitivity is not fast enough, a double click responds as two single clicks. On earlier Win versions, it will be somewhere in Settings >> Devices and then diddle around with mouse options.
Thanks Doc_man.
The double click speed seems to be ok for textboxes and labels so I don't think that's the problem but it's worth a try to speed it up a bit. The limiting factor might be my old fingers can't move fast enough!
 
You could use an option group with three buttons like this using the Wingdings font.
1734320571180.png

To assist with coding, the option group tag property could be a clue to the column/field name and data type.
 
Last edited:
I've got a work around for colouring the active label.
It meant renaming the labels to "lbl" and the field names they're attached to, so the field "Access:" has a label "lblAccess" etc.
The string going to the sub "Setindex" has " Desc" attached on the double click, so "Access Desc". That takes care of the indexing.
The string "str" is then passed to the "recolour" sub with the " Desc" stripped off and "lbl" added to the front.
A check to see if ctl.name = str and I know which label to recolour as active while resetting the rest.
As for the pretties, I gave the labels a shadow. It looks a bit better than just flat.

Tempvars!colouron is a limey green for the indexed column header. I use this throughout the system to indicate the active control.


Thank you all for your suggestions.
They're much appreciated.
John

Code:
Private Sub setIndex(str As String)
    Me.OrderBy = str
    str = "lbl" & IIf(InStr(str, "Desc") > 0, Left(str, Len(str) - 5), str)
    recolour str
End Sub

Private Sub recolour(str As String)
    Dim ctl As Control
    For Each ctl In Me.Section(acHeader).Controls
        If ctl.ControlType = acLabel And ctl.Name <> "lblgoto" Then
            If ctl.Name = str Then
                ctl.BackColor = TempVars!colouron
            Else
                ctl.BackColor = RGB(218, 87, 115)
            End If
        End If
    Next ctl
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom