3

I have a MS Access database that has a switchboard on it that opens different forms within the database. For some reason, some of the users like to double click the buttons that open the different forms. This is a problem because one of the forms that opens happens to have a checkbox right where the button that opens it is, so when they double click the button to open the form, it causes the checkbox to toggle and change it's value. It's a constant problem.

I tried adding a double click event handler that would essentially do nothing, but it's not firing and the form still opens and the checkbox keeps getting toggled.

I've tried user education, I've tried telling them that it's causing problems, but they don't seem to get it. Is it possible to only let a button work when it's clicked one time, and if it's clicked twice it just doesn't work, or it throws an error at them to shame them?

Zachary Weber
  • 455
  • 3
  • 15
  • 1
    Place the checkbox in question somewhere else ;-) – Storax May 05 '22 at 19:56
  • Why would clicking a button cause a check box to toggle? Are they actually clicking on check box? – June7 May 05 '22 at 20:07
  • @Storax that's easier said than done unfortunately. It's just where the checkbox is. – Zachary Weber May 05 '22 at 20:10
  • @June7 It causes it to toggle because when the button is double clicked, the first "click" causes the form to open and the second one toggles the checkbox on the form that opened. The checkbox happens to appear right over where the button that opens the form is located. – Zachary Weber May 05 '22 at 20:11
  • User 'double click' isn't fast enough to be a true double-click. These are two single clicks. So the form is opening between clicks. Agree with @Storax, move the checkbox and see what happens. – June7 May 05 '22 at 20:17
  • Actually, AFAIK, when a button is set with single click event code it will always register first click as single click so don't think can even have a double click event work when single click event is coded. So an option is to code double click event instead and make everyone double click. What is checkbox an indication of? I wonder if issue is checkbox has focus when form opens. I need to experiment. – June7 May 05 '22 at 20:29
  • Managed to replicate issue. Checkbox so tiny doesn't have to be moved much to get it out of alignment with button. – June7 May 05 '22 at 21:36
  • @June7: If the checkbox has an associated label, then clicking on the label will toggle the checkbox. This can make the click target quite large even though the checkbox itself is tiny. – mwolfe02 May 08 '22 at 03:54
  • Change your event to a double-click event and inform your users that you had to do it to protect data integrity due to specific scenarios where a single click would effect negative results. That way they think you're doing the "good lord's work" and not just compensating for PEBKAC. :) – billyhoes May 10 '22 at 01:36

2 Answers2

4

One way to solve this is:

When the second forms opens set the following properties in Form_Open:

Private Sub Form_Open(Cancel As Integer)
    Me.AllowEdits = False   ' Will prevent form from being edited
    Me.TimerInterval = 500  ' Will trigger Form_Timer after 500 miliseconds
End Sub

and in the Form_Timer event (kicks in after 500 miliseconds)

Private Sub Form_Timer()
    Me.AllowEdits = True    ' Allow edit again
    Me.TimerInterval = 0    ' Stop timer
End Sub

With this the second form will not be possible to edit the first half a second while the second click comes.

Micke
  • 141
  • 3
0

You can try this code under the double click event of the button

    Private Sub Command1_DblClick(Cancel As Integer)
    Cancel = True
    End Sub

In my case the command button name is Command1

Sola Oshinowo
  • 519
  • 4
  • 13