dbTalk Databases Forums  

Prevent Code running if user clicks command button twice

comp.databases.ms-access comp.databases.ms-access


Discuss Prevent Code running if user clicks command button twice in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default Prevent Code running if user clicks command button twice - 09-05-2011 , 02:27 AM






I can't work out how to intercept a second call to a function if a user
clicks a command button a second time in rapid succession. I've tried using
DoEvents but that doesn't work.
If I use a message box, that does the trick, but I don't want a message box
to appear at this point.
Using Access 2002 and 2010.

--
Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Douglas J Steele
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-05-2011 , 09:02 AM






Try declaring a module-level variable, setting it to a specific value upon
first invocation, then setting it back when the function's complete. In that
way, you can check the value of the variable in the Click event.

"Bob Darlington" wrote in message
news:4e647988$0$2446$afc38c87 (AT) news (DOT) optusnet.com.au...

I can't work out how to intercept a second call to a function if a user
clicks a command button a second time in rapid succession. I've tried using
DoEvents but that doesn't work.
If I use a message box, that does the trick, but I don't want a message box
to appear at this point.
Using Access 2002 and 2010.

--
Bob Darlington
Brisbane

Reply With Quote
  #3  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-05-2011 , 05:48 PM



Thanks Douglas.
I should have thought about that.

--
Bob Darlington
Brisbane
"Douglas J Steele" <NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote

Quote:
Try declaring a module-level variable, setting it to a specific value upon
first invocation, then setting it back when the function's complete. In
that way, you can check the value of the variable in the Click event.

"Bob Darlington" wrote in message
news:4e647988$0$2446$afc38c87 (AT) news (DOT) optusnet.com.au...

I can't work out how to intercept a second call to a function if a user
clicks a command button a second time in rapid succession. I've tried
using
DoEvents but that doesn't work.
If I use a message box, that does the trick, but I don't want a message
box
to appear at this point.
Using Access 2002 and 2010.

--
Bob Darlington
Brisbane

Reply With Quote
  #4  
Old   
Tony Toews
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-05-2011 , 09:51 PM



On Mon, 5 Sep 2011 17:27:12 +1000, "Bob Darlington"
<bob (AT) notheredpcman (DOT) com.au> wrote:

Quote:
I can't work out how to intercept a second call to a function if a user
clicks a command button a second time in rapid succession. I've tried using
DoEvents but that doesn't work.
Actually DoEvents allows this to happen although you frequently want
DoEvents.

Also consider setting the hour glass as a psychological barrier to
waiting. Do ensure you set the hour glass back in the error handling
though. Docmd.Hourglass

Finally if appropriate, such as a recordset loop or running 10 queries
in a row, having a progress bar in your app. See the Progress Bars
and Microsoft Access page at
http://www.granite.ab.ca/access/progressbar.htm for more info.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-06-2011 , 09:07 AM



On 06/09/2011 03:51:41, Tony Toews wrote:
Quote:
On Mon, 5 Sep 2011 17:27:12 +1000, "Bob Darlington"
bob (AT) notheredpcman (DOT) com.au> wrote:

I can't work out how to intercept a second call to a function if a user
clicks a command button a second time in rapid succession. I've tried using
DoEvents but that doesn't work.

Actually DoEvents allows this to happen although you frequently want
DoEvents.

Also consider setting the hour glass as a psychological barrier to
waiting. Do ensure you set the hour glass back in the error handling
though. Docmd.Hourglass

Finally if appropriate, such as a recordset loop or running 10 queries
in a row, having a progress bar in your app. See the Progress Bars
and Microsoft Access page at
http://www.granite.ab.ca/access/progressbar.htm for more info.

Tony
And if you feel like a pretty rainbow coloured progress meter, I have one
that I am quite happy to email to anyone

Phil

Reply With Quote
  #6  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-07-2011 , 06:43 PM



"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in
news:4e647988$0$2446$afc38c87 (AT) news (DOT) optusnet.com.au:

Quote:
I can't work out how to intercept a second call to a function if
a user clicks a command button a second time in rapid succession.
I've tried using DoEvents but that doesn't work.
If I use a message box, that does the trick, but I don't want a
message box to appear at this point.
Using Access 2002 and 2010.
How quickly are you talking about? I guess it has to be slower than
the code takes to run. Would it be too kludgy to just put in a loop
to make it take longer for the function to run, so that the second
click is ignored?

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #7  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-07-2011 , 08:35 PM



"Tony Toews" <ttoews (AT) telusplanet (DOT) net> wrote

Quote:
On Mon, 5 Sep 2011 17:27:12 +1000, "Bob Darlington"
bob (AT) notheredpcman (DOT) com.au> wrote:

I can't work out how to intercept a second call to a function if a user
clicks a command button a second time in rapid succession. I've tried
using
DoEvents but that doesn't work.

Actually DoEvents allows this to happen although you frequently want
DoEvents.

Also consider setting the hour glass as a psychological barrier to
waiting. Do ensure you set the hour glass back in the error handling
though. Docmd.Hourglass

Finally if appropriate, such as a recordset loop or running 10 queries
in a row, having a progress bar in your app. See the Progress Bars
and Microsoft Access page at
http://www.granite.ab.ca/access/progressbar.htm for more info.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Thanks Tony.
I didn't understand your first paragraph.
But I'll try the progress bar.

--
Bob Darlington
Brisbane

Reply With Quote
  #8  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-07-2011 , 08:38 PM



"David-W-Fenton" <NoEmail (AT) SeeSignature (DOT) invalid> wrote

Quote:
"Bob Darlington" <bob (AT) notheredpcman (DOT) com.au> wrote in
news:4e647988$0$2446$afc38c87 (AT) news (DOT) optusnet.com.au:

I can't work out how to intercept a second call to a function if
a user clicks a command button a second time in rapid succession.
I've tried using DoEvents but that doesn't work.
If I use a message box, that does the trick, but I don't want a
message box to appear at this point.
Using Access 2002 and 2010.

How quickly are you talking about? I guess it has to be slower than
the code takes to run. Would it be too kludgy to just put in a loop
to make it take longer for the function to run, so that the second
click is ignored?

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
Thanks David,
I'm talking 'as fast my my old fingers will go', but some of my users seem
to do it as a matter of course.
I'll try a timer loop to see what happens.

--
Bob Darlington
Brisbane

Reply With Quote
  #9  
Old   
Tony Toews
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-08-2011 , 03:58 PM



On Thu, 8 Sep 2011 11:35:09 +1000, "Bob Darlington"
<bob (AT) notheredpcman (DOT) com.au> wrote:

Quote:
I didn't understand your first paragraph.
If you didn't have a DoEvents in there then the user might not have
been able to click the button.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/

Reply With Quote
  #10  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Prevent Code running if user clicks command button twice - 09-14-2011 , 11:47 PM



Thanks Tony.
You were correct. I've removed the DoEvents, and the problem is gone.

--
Bob Darlington
Brisbane
"Tony Toews" <ttoews (AT) telusplanet (DOT) net> wrote

Quote:
On Thu, 8 Sep 2011 11:35:09 +1000, "Bob Darlington"
bob (AT) notheredpcman (DOT) com.au> wrote:

I didn't understand your first paragraph.

If you didn't have a DoEvents in there then the user might not have
been able to click the button.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.