martijnverduin
New member
- Local time
- Today, 20:59
- Joined
- Apr 19, 2011
- Messages
- 1
Hi all,
at work I'm trying to get my Access application to run at a certain time (initiated through Windows Task Scheduler) which works. Upon start, a form named startup_form is opened. It checks the current time so that only when it's opened after business hours (20h00 or later) the desired procedure ("Backup_mail_procedure": backup operations and sending an e-mail programmatically) will start. After the procedure, which runs flawlessly, I'm trying to shutdown the PC:
The strange thing is that when I leave my PC on when I go home, it will not shut down. When I change the working window to let's say after 9h00 in the morning (>8) and schedule the MDB to run at 10, it does work i.e. PC shuts down with no problems. When I change it back to >19 and schedule it at 20h30: no luck. What might be the problem?
Any help is appreciated!
Cheers, Martijn
at work I'm trying to get my Access application to run at a certain time (initiated through Windows Task Scheduler) which works. Upon start, a form named startup_form is opened. It checks the current time so that only when it's opened after business hours (20h00 or later) the desired procedure ("Backup_mail_procedure": backup operations and sending an e-mail programmatically) will start. After the procedure, which runs flawlessly, I'm trying to shutdown the PC:
Code:
Private Sub Form_Open(Cancel As Integer)
If Hour(Now()) > 19 Then 'only works after 8 pm
DoCmd.Close acForm, "startup_form"
Backup_mail_procedure
fTerminateWin
Application.Quit
Else
End If
End Sub
Public Sub fTerminateWin()
Shell "C:\WINDOWS\system32\shutdown.exe -s -f -t 30", vbNormalNoFocus
End Sub
The strange thing is that when I leave my PC on when I go home, it will not shut down. When I change the working window to let's say after 9h00 in the morning (>8) and schedule the MDB to run at 10, it does work i.e. PC shuts down with no problems. When I change it back to >19 and schedule it at 20h30: no luck. What might be the problem?
Any help is appreciated!
Cheers, Martijn