473,388 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 7038
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_Click

SaveButton.Enable = False
Timer1.Enable = False

End Sub

Sub Timer1_Timer

SaveButton.Enable = True
Timer1.Enable = False

End Sub

Hope this helps,

Brian


Ja***@agiftforteaching.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_Click

SaveButton.Enable = False
Timer1.Enable = False

End Sub

Sub Timer1_Timer

SaveButton.Enable = 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(varLastSave) 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***@agiftforteaching.org wrote in news:1162414012.599181.160730
@i42g2000cwa.googlegroups.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 DatetoNearestHour(ByVal vdate As Date) As Date
DatetoNearestHour = DateSerial( _
Year(vdate), _
Month(vdate), _
Day(vdate)) _
+ _
TimeSerial(Hour(vdate), 0, 0)
End Function

or

Public Function DatetoNearestHourB(ByVal vdate As Date) As Date
DatetoNearestHourB = 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_mdacroadmap.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
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...
8
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...
9
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;...
6
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
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...
3
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...
0
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...
2
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.