Solved

access 2007 timer

Posted on 2012-04-03
11
550 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
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.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

860 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