We need to prevent “Double Clicking†of a button on a Form

B

Brad

What is the best way to prevent “Double Clicking†of a button on a Form?

We have an Access 2007 Form which has a button this initiates Excel. This
is used when our users need to open up Excel in order to change data in a
specific spreadsheet.

For many years, our users have opened up Excel with a Double Click on a
desktop icon. They now Double Click a button on an Access 2007 form and
Excel is opened up two times.

What is the best way to prevent this? I have thought about disabling the
button for a few seconds after the first Single Click. I believe that this
would work, but I am curious if there is a better method to do this.

Thanks,
Brad
 
S

Stuart McCall

Brad said:
What is the best way to prevent "Double Clicking" of a button on a Form?

We have an Access 2007 Form which has a button this initiates Excel. This
is used when our users need to open up Excel in order to change data in a
specific spreadsheet.

For many years, our users have opened up Excel with a Double Click on a
desktop icon. They now Double Click a button on an Access 2007 form and
Excel is opened up two times.

What is the best way to prevent this? I have thought about disabling the
button for a few seconds after the first Single Click. I believe that
this
would work, but I am curious if there is a better method to do this.

Thanks,
Brad

Say your button is called Command0, all you need to do is cancel the
doubleClick event, like this:

Private Sub Command0_DblClick(Cancel As Integer)
Cancel = True
End Sub
 
D

Dirk Goldgar

Stuart McCall said:
Say your button is called Command0, all you need to do is cancel the
doubleClick event, like this:

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


Nice trick, Stuart! I didn't know it would work like that.
 
S

Stuart McCall

Dirk Goldgar said:
Nice trick, Stuart! I didn't know it would work like that.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

I had a similar problem with some users a couple of years ago. Went through
trying to hook the mouse click via API. 2 days later I suddenly noticed the
Cancel parameter...
 
D

Douglas J. Steele

What about a variable (either Static, or global to the module) that's set
the first time the Click event fires, and checked each time?
 
M

Mike Painter

Brad said:
What is the best way to prevent "Double Clicking" of a button on a
Form?

We have an Access 2007 Form which has a button this initiates Excel.
This is used when our users need to open up Excel in order to change
data in a specific spreadsheet.

For many years, our users have opened up Excel with a Double Click on
a desktop icon. They now Double Click a button on an Access 2007
form and Excel is opened up two times.

What is the best way to prevent this? I have thought about disabling
the button for a few seconds after the first Single Click. I believe
that this would work, but I am curious if there is a better method to
do this.
If they still use double click everyplace else, why not be consistant and
change your application to what they are used to?
 
J

Jeanette Cunningham

I have had a similar problem with A2007 and creating a new ClientID in one
app.
User double clicks, but A2007 registers this as 2 single clicks and creates
2 new client id's, one after the other, but time stamp shows both created in
the same second.

On my computer, I can double click as much as I like on the same database
creating the same new ClientID, but never create 2 new CleintID's at the
same time. The only thing that worked for me was to do a duplicate check and
remove the second, unwanted ClientID after it was created but before the
user saw it.

The same user also has a problem with submenus from the ribbon - she moves
the mouse so quickly that the submenu often shows a blank menu. She has a
very slippery mouse mat and a small mouse that zips around the screen so
quickly that she loses control of it.

I have discussed the option of changing the mouse settings for double
click - but she finds that the setting works very well with all her other
software - of which there are many different ones she uses every day.

I suggest that you use the code that checks to see if excel is already open,
and do not create another new instance of excel if it is already open. You
will find the code here
http://www.mvps.org/access/api/api0007.htm



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Bob Quintal

What about a variable (either Static, or global to the module)
that's set the first time the Click event fires, and checked each
time?
Or what about, since the users want to double-click, moving the code
from the on_click event to the on_dblClick event and not using the
on_click event at all.
 
B

Bob Quintal

What about a variable (either Static, or global to the module)
that's set the first time the Click event fires, and checked each
time?
Or what about, since the users want to double-click, moving the code
from the on_click event to the on_dblClick event and not using the
on_click event at all.
 
D

Dirk Goldgar

Linq Adams via AccessMonster.com said:
"They now Double Click a button on an Access 2007 form and Excel is opened
up
two times."

If there was originally no code in the DoubleClick event, the OnClick
event
was set to open up Excel, and the user "Double Clicking" the button opened
Excel twice, then Access wasn't accepting this so called "Double Click" as
an
actual Double Click, but rather as a single click performed twice,
probably
because the user was performing it slowly. That being true, I'm not sure
putting anything in the DoubleClick event is going to help. The OP may
have
to, in the beginning of the OnClick event, move focus to another control
and
then Disable the command button.


That is what I thought, but having faith in Stuart I went ahead and tested.
This is what I found:

1. If there is no DblClick event procedure for the button, double-clicking
the button makes the Click event fire twice.

2. If there is a DblClick event procedure, and that procedure doesn't cancel
the event, double-clicking the button causes this sequence of events to
fire:

Click
DblClick
Click

I already knew this, in principle, because of prior work I've done
investigating the difference between the event sequence when double-clicking
labels versus command buttons. The special event sequence for command
buttons is documented in the help file.

3. If there is a DblClick event procedure, and that procedure *does* cancel
the event (by setting the Cancel argument to True), double-clicking the
button causes this sequence of events to fire:

Click
DblClick

As you see, the Click event does not fire the second time.

Therefore, it isn't necessary to set up a timer, or compare the time between
clicks, to suppress the double-clicking of a command button. I think it was
very clever of MS to set it up that way, and a smart solution by Stuart to
Brad's problem.
 
S

Stuart McCall

having faith in Stuart I went ahead and tested

That's some faith you have in me if you had to test anyway. <g>
 
D

Dirk Goldgar

Stuart McCall said:
That's some faith you have in me if you had to test anyway. <g>


LOL

Trust, but verify.

If I hadn't had faith I'd have just said, "Aw, he's nuts."

Merry Christmas, Stuart.
 
A

Albert D. Kallal

3. If there is a DblClick event procedure, and that procedure *does*
cancel the event (by setting the Cancel argument to True), double-clicking
the button causes this sequence of events to fire:

Click
DblClick

As you see, the Click event does not fire the second time.

Therefore, it isn't necessary to set up a timer, or compare the time
between clicks, to suppress the double-clicking of a command button. I
think it was very clever of MS to set it up that way, and a smart solution
by Stuart to Brad's problem.

Yes...that is quite neat...and this solution is new to me also........
 
D

David W. Fenton

What is the best way to prevent ƒ oDouble Clickingƒ of a button
on a Form?

The discussion ensuing from this question has been very fruitful,
and I've added the solution to my quiver of techniques. Strangely
enough, I have never encountered this problem, possibly because I'm
responsible for the training of most of my users, and it's drilled
into them from the beginning that a button is double-clicked and an
icon is single-clicked. I don't use the popular mouse-overs that
make flat icons look like buttons when the mouse is over them -- if
it's a button, it looks like a button all the time. I believe that
the use by MS and other software vendors of flat icons that get a 3D
frame on MouseOver is the cause of much of the user confusion on
what you doubleclick and what you singleclick -- if it's flat, it
looks like an icon, and icons should doubleclicked. Even users of
mine who have that distinction very firmly in mind sometimes get
confused by the QuickLaunch toolbar in the TaskBar, since
QuickLaunch icons don't look like buttons until you mouse over them.
Yet, they never doubleclick taskbar buttons (because these look like
buttons all the time).

I'm not claiming this is the cause of users doubleclicking in the
original poster's question, just that it's better to use plain old
boring command buttons rather than getting fancy with mouseovers
that make buttons look like icons and will tempt users to
doubleclick.

Another source of unwanted clicks is user impatience. That is, they
click and they see nothing happening, so they click again. The
solution to that is to always respond to any click with an indicator
that something is happening. DoCmd.Hourglass True is the easiest,
but it's often going to be ignored. You could alternatively pop up a
form telling the user that their requested action is being
initiated, but then you have to have some termination event that
will close the form. In the case of opening an Excel spreadsheet,
it's difficult to know what is most appropriate. Detecting that the
Excel app is running is not necessarily going to work, as that can
happen long before Excel is visible, or Excel could already be
running when the user clicks the button. Testing to see if the
requested workbook is open in the instance of Excel is another way,
since you just need to check the title bar text (which includes both
the app and workbook names).

The point is that you can avoid the impatient clicks by judicious
use of immediate feedback telling the user "Yes, I got your click
and something is happening!" What that feedback will be will be will
depend on what you're doing in the OnClick() event of your command
button.
 
D

Dirk Goldgar

David W. Fenton said:
Strangely
enough, I have never encountered this problem, possibly because I'm
responsible for the training of most of my users, and it's drilled
into them from the beginning that a button is double-clicked and an
icon is single-clicked.

Or perhaps the other way around? :)
 
D

David W. Fenton

I'm
responsible for the training of most of my users, and it's drilled
into them from the beginning that a button is double-clicked and
an icon is single-clicked.

And, as Dirk points out, I said exactly the opposite of what I
meant. That should read:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top