Solved

access 2007 timer

Posted on 2012-04-03
11
555 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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.

730 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