Using timer as Alarm clock

O

OlszanskiA

I am trying to set up a simple form where I click a button and 1 hour later
it tells me time is up. I copied the code from MS Access VB help, but I get
the error message regarding the line Start = Timer: "Compile Error: Expected
Variable or Procedure, not Project"

Can you assit me. I've tried may different ways to no avail.
________________________
The code:
Private Sub Alarm_Click()

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If

End Sub
 
S

Sergey Poberezovskiy

On a click of you button set up Form's TimerInterval property to 3,600,000 =
60min*60sec*1000ms, and then on your Timer event popup a MsgBox with the
alarm message and re-set the TimerInterval property to 0.

HTH
 
6

'69 Camaro

Hi.
Can you assit me.

Sure. Open the VB Editor (press <ALT><F11>), and select the Tools -> Timer
Properties... menu item to open the Timer - Project Properties dialog window.
Change the project name from Timer to TimerDB (or choose another name other
than a Reserved word or is already in use elsewhere). Select the "OK" button
to close the dialog window, then compile the code again.

The reason you're running into this problem is that this example code is
trying to use the form's Timer (a Reserved word) event that your database
application is also using as the project name, Timer. Never use Reserved
words for your identifiers, or you'll run into bugs that are difficult -- and
often very time-consuming -- to track down and fix.

For lists of the Reserved words to avoid, please see the following Web pages:

http://support.microsoft.com/default.aspx?id=321266

http://support.microsoft.com/default.aspx?scid=286335

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
O

OlszanskiA

Perfect. I thought I might have used a reserved word, but when I changed my
forms name and my database name, it still didn't work. Your fix was so easy!
Thank you too for the list of reserved words.
 

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

Similar Threads


Top