Solved

access 2007 timer

Posted on 2012-04-03
11
542 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37804104
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
ID: 37804543
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37805599
try


CurrentDb.Execute "update tblShutDownInfo set  ShutDown=False"
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:centralmike
ID: 37806700
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37806774
ok...
0
 

Author Comment

by:centralmike
ID: 37807800
Here is the file.  I can remembered if I sent this already.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37807806
still, no file
0
 

Author Comment

by:centralmike
ID: 37807923
Sorry About that.
mytest.accdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37808040
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
ID: 37808169
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 37808254
did you follow my instruction at http:#a37808040 ?
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

803 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