Solved

access 2007 timer

Posted on 2012-04-03
11
512 Views
Last Modified: 2012-04-12
I have a timer on hidden form that shuts down my application at 7 pm each evening for updates.  The problem i am having when users tries logon again the application justs keep shutting down because the timer event has already past  Is there anyway to disable the timer event after a period of time through code?  Currently I have to hold  down the shift key(11) to keep that application from closing. I have attached a copy my code below.
0
Comment
Question by:centralmike
  • 6
  • 5
11 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
create a table (tblShutDownInfo) with a DateTime Field [varDate] and a YesNo field named [ShutDown]

at the startUp of your db, compare the current date with the value of varDate
If dlookup("varDate","tblShutDownInfo") < Date then
' update the table
   currentdb.execute "update tblShutDownInfo set vardate=Date(), Shutdown=-1"

end if

in your Timer event
check the values of table tblShutDownInfo..

If dlookup("varDate","tblShutDownInfo") = Date And dlookup("ShutDown","tblShutDownInfo")=True  then
   'update the table
    currentdb.execute "update tblShutDownInfo set  Shutdown=0"

   'run shutdown codes here

end if


got the idea?
0
 

Author Comment

by:centralmike
Comment Utility
Can not figure why the shutdown field is not updating? Set the field to a yes/no field but the table never gets updated. A set the vardate field to yesterday and it updates with no problem with the current date.

Private Sub Form_Timer()
  Dim dtCloseTime As Date
    Dim dtCurTime As Date


If DLookup("varDate", "tblShutDownInfo") = Date And DLookup("ShutDown", "tblShutDownInfo") = True Then
   'update the table
    CurrentDb.Execute "update tblShutDownInfo set  ShutDown=0"

   'run shutdown codes here
   dtCloseTime = Format(#11:19:05 PM#, "hh:MM:ss")
   dtCurTime = Format(Time(), "hh:mm:ss")
   
   If dtCurTime > dtCloseTime Then
    Call ExitApplication
   End If


End If
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
try


CurrentDb.Execute "update tblShutDownInfo set  ShutDown=False"
0
 

Author Comment

by:centralmike
Comment Utility
I must be missing something.  I will send you a copy of the database I am working with. If you take a look at my code to see if I am doing something wrong. I have code in the open of event of the main form and code in the form1 with timer event.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
ok...
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:centralmike
Comment Utility
Here is the file.  I can remembered if I sent this already.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
still, no file
0
 

Author Comment

by:centralmike
Comment Utility
Sorry About that.
mytest.accdb
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
the codes in the open event of the main form is

Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenForm "form1"
'   at the startUp of your db, compare the current date with the value of varDate
If DLookup("varDate", "tblShutDownInfo") < Date Then
' update the table
   CurrentDb.Execute "update tblShutDownInfo set vardate=Date(), Shutdown =True"

End If

End Sub

so open the db, change the date "varDate" to 4/3/2012
close the db and open again
0
 

Author Comment

by:centralmike
Comment Utility
It looks like the tblshutdowninfo is being updated.  The form1 doesn't seem to be shuting down at the schedule time now.  Did you look at the timer event of form1?  Thanks.  I would just like the database to shutdown at a certain time in the evening.  When the user comes in the next day or after midnight the database should be available.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
did you follow my instruction at http:#a37808040 ?
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL VBA Syntax when using NULL 17 32
Subform "Column Choose" Functionality 3 17
Dateadd 3 19
How calculate median 5 37
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now