473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timer to Enable/Disable a Button

Hello,
I am having a problem with a MS Access 2000 Database that I
partially helped create. I am recording visits that registered
customers make to our store. I have a list of all the elidgible people
that can shop, and when I click a button, it records a visit for today
in Date/Time format.

My problem is that the button that records the visit can be
clicked multiple times, and I am trying to find a way to lock it for a
few seconds so that itchy double-clickers can't record more than one
visit every 5 seconds. Basically, I am looking for code in VB that
"upon click, disable such&such button for 5 seconds."

If anyone can help, it would be greatly appreciated.

Thanks-

Nov 1 '06 #1
3 7090
James,

Add a timer to your form and set the interval property to like 5000 (5
sec's), and the Enabled property to False then...

Sub SaveButton_Clic k

SaveButton.Enab le = False
Timer1.Enable = False

End Sub

Sub Timer1_Timer

SaveButton.Enab le = True
Timer1.Enable = False

End Sub

Hope this helps,

Brian


Ja***@agiftfort eaching.org wrote:
Hello,
I am having a problem with a MS Access 2000 Database that I
partially helped create. I am recording visits that registered
customers make to our store. I have a list of all the elidgible people
that can shop, and when I click a button, it records a visit for today
in Date/Time format.

My problem is that the button that records the visit can be
clicked multiple times, and I am trying to find a way to lock it for a
few seconds so that itchy double-clickers can't record more than one
visit every 5 seconds. Basically, I am looking for code in VB that
"upon click, disable such&such button for 5 seconds."

If anyone can help, it would be greatly appreciated.

Thanks-
Nov 1 '06 #2

Brian Puffer wrote:
James,

Add a timer to your form and set the interval property to like 5000 (5
sec's), and the Enabled property to False then...

Sub SaveButton_Clic k

SaveButton.Enab le = False
Timer1.Enable = False

End Sub

Sub Timer1_Timer

SaveButton.Enab le = True
Timer1.Enable = False

End Sub

Hope this helps,

Brian
This might work well in VB, but Access does not have a native Timer
control.

You could probably rig up something similar with the form's Timer event
but I wouldn't bother. In gross terms I would simply set up the click
event of your Save button to save the time of the last successful save.
On each subsequent click check to see if 5 seconds have elapsed since
that time. If not, display a message saying "sorry, you have to wait 5
seconds". Otherwise, save the record and save the new successful save
time. Something like

Static varLastSave As Variant

If IsEmpty(varLast Save) Then
' save record here
MsgBox "Save successful."
varLastSave = Now
Else
If DateDiff("s", varLastSave, Now) < 5 Then
MsgBox "Sorry, you have to wait."
Else
' save record here
MsgBox "Save successful."
varLastSave = Now
End If
End If

Nov 2 '06 #3
Ja***@agiftfort eaching.org wrote in news:1162414012 .599181.160730
@i42g2000cwa.go oglegroups.com:
Hello,
I am having a problem with a MS Access 2000 Database that I
partially helped create. I am recording visits that registered
customers make to our store. I have a list of all the elidgible people
that can shop, and when I click a button, it records a visit for today
in Date/Time format.

My problem is that the button that records the visit can be
clicked multiple times, and I am trying to find a way to lock it for a
few seconds so that itchy double-clickers can't record more than one
visit every 5 seconds. Basically, I am looking for code in VB that
"upon click, disable such&such button for 5 seconds."

If anyone can help, it would be greatly appreciated.

Thanks-

I would be inclined to modify the date before storing it and to create a
unique index on the person and that modified date.

A function to return just the date and hour might be:

Public Function DatetoNearestHo ur(ByVal vdate As Date) As Date
DatetoNearestHo ur = DateSerial( _
Year(vdate), _
Month(vdate), _
Day(vdate)) _
+ _
TimeSerial(Hour (vdate), 0, 0)
End Function

or

Public Function DatetoNearestHo urB(ByVal vdate As Date) As Date
DatetoNearestHo urB = CDate(Fix(24 * CDbl(vdate)) / 24)
End Function

Buttons are bad; they are a carry-over from dos; buttons with peculiar
code are badder.

--
Lyle Fairfield

from http://msdn.microsoft.com/library/de...l=/library/en-
us/dnmdac/html/data_mdacroadma p.asp

Obsolete Data Access Technologies
Obsolete technologies are technologies that have not been enhanced or
updated in several product releases and that will be excluded from future
product releases. Do not use these technologies when you write new
applications. When you modify existing applications that are written
using these technologies, consider migrating those applications to
ADO.NET.
The following components are considered obsolete:
....
Data Access Objects (DAO): DAO provides access to JET (Access) databases.
This API can be used from Microsoft Visual Basic®, Microsoft Visual C++®,
and scripting languages. It was included with Microsoft Office 2000 and
Office XP. DAO 3.6 is the final version of this technology. It will not
be available on the 64-bit Windows operating system.
.....
Nov 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5661
by: martinm69x | last post by:
Hey all, I've been working on the code for a kernel timer which will report real time, CPU time, user time and kernel time on the operation of fibonacci method. The way im doing it is keeping track of the parent and two child times (using fork()). I can get parent times to come up, however i do not think they are
8
2773
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get called? private System.Windows.Forms.Timer timerDF; this.timerDF = new System.Windows.Forms.Timer(this.components);
9
7265
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null; Let's declare a constant Int32 m_TimePeriod = 10000;
6
6143
by: whtinkm | last post by:
Hi, All Recently, my project need some code like following: using System; using System.Threading; namespace MyTimerTest { class Class1 {
7
2374
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly reset I put some extra code in the subs that enable and disable the timer. They fire as expected. To test this I added a second timer with a 1 second interval. The event for this time would output the enabled status of the first timer and its...
3
2506
by: John Salerno | last post by:
I'd be curious to know if this works any differently on other computers/platforms or while other things are happening in the background. I can't tell if it's the Timer object that isn't keep accurate time (although a test with time.time() seems to show that it is), or if I'm just messing up my algorithm to fill the progress bar. If I put in 10 seconds, the progress bar will be fully filled at the end, but if you put 30, it doesn't. As the...
0
1404
by: ArmyGeek | last post by:
Hey Guys, Im trying to figure out how to Disable a Button after a user clicks it, then Enable the Button if the user emptys a Text Box where the user can input information. I also want to automaticaly Enable the Button and clear the Text Box if the user doesn't do anything for a specified amount of time after clicking the Button. Any Help with this would be appreciated. Thanks
2
6576
by: ArmyGeek | last post by:
Hey Guys, Im trying to figure out how to Disable a Button after a user clicks it, then Enable the Button if the user emptys a Text Box where the user can input information. I also want to automaticaly Enable the Button and clear the Text Box if the user doesn't do anything for a specified amount of time after clicking the Button. Any Help with this would be appreciated. Thanks
3
3838
by: Beemer Biker | last post by:
Unaccountably, I cannot re-enable a timer from an background thread. The disable works fine, I just cannot get it to start back up. There is no method "InvokeRequired" like there is for windows.forms.controls and I get no error message about cross thread so I am not sure where the problem is. I have a "SerialPoll_timer" that every second requests status from a device on an RS232 port. I use this to determine if the device is on line. ...
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.