Solved

access 2007 timer

Posted on 2012-04-03
11
528 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
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 119

Expert Comment

by:Rey Obrero
ID: 37805599
try


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

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 119

Expert Comment

by:Rey Obrero
ID: 37806774
ok...
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

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

Expert Comment

by:Rey Obrero
ID: 37807806
still, no file
0
 

Author Comment

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

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

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

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

919 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

24 Experts available now in Live!

Get 1:1 Help Now