Results 1 to 15 of 15
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    Task Scheduler Issue

    So, I have created a test database hoping the Task Scheduler would execute every night. I think I've set it correctly, but something is not quite right. I believe I have set the parameters correctly. Please see image for reference. When I copied the path of the program file and pasted to window explorer, it launches. When I copied and pasted the file to window explorer, it launches the file. I scheduled the task at certain time just to see if it executed. When I look at the history, it say it has, but I know for a fact that it hasn't. 1) I didn't see the file open upon the time it supposedly happened. 2) I have set a form to open upon AutoExec macro. When the form opens, I have a procedure that inserts a line to a table.



    When I manually open the file, I see it working perfectly. The table has a log of the times file has opened. It only has the log of all the times that I manually opened the file, not from the times that task scheduler triggered (supposedly).

    Does anyone know what can be happening here?Click image for larger version. 

Name:	Scheduler.jpg 
Views:	25 
Size:	127.6 KB 
ID:	33530

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Several possible settings you might need to change:
    1. General tab – change to – Run whether user logged in or not
    2. Conditions tab – change to - Wake the computer to run this task
    3. Settings tab – tick Run task as soon as possible after scheduled task is missed

    The attached file contains some guidance I wrote for a client several years ago.
    Some of it is specific to a particular application but it should give you info you can adapt

    Running SDA Link in Task Scheduler.zip
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Another thought, I could never get scheduled tasks to run an accdb, just an mdb. That may have changed since then. For accdb's I create a vbs script and execute that from scheduled tasks. The script opens the accdb.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by ridders52 View Post
    Several possible settings you might need to change:
    1. General tab – change to – Run whether user logged in or not
    2. Conditions tab – change to - Wake the computer to run this task
    3. Settings tab – tick Run task as soon as possible after scheduled task is missed

    The attached file contains some guidance I wrote for a client several years ago.
    Some of it is specific to a particular application but it should give you info you can adapt

    Running SDA Link in Task Scheduler.zip
    I changed all the parameters and just set another trigger. Once again, according to the history, it ran, but I know it didn't. Do I have to be idle or not actively using the computer for a scheduled task to be executed?

  5. #5
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by pbaldy View Post
    Another thought, I could never get scheduled tasks to run an accdb, just an mdb. That may have changed since then. For accdb's I create a vbs script and execute that from scheduled tasks. The script opens the accdb.
    I can certainly try it out. Would you mind providing me some guidance on the script and where to insert the script?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by LonghronJ View Post
    Would you mind providing me some guidance on the script and where to insert the script?
    The script is pretty complicated, but I'll try.

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "msaccess.exe C:\AccessAp\SendWebResEmail.accdb"

    I put the file in the same place the accdb is, but it doesn't really matter.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Quote Originally Posted by LonghronJ View Post
    I changed all the parameters and just set another trigger. Once again, according to the history, it ran, but I know it didn't. Do I have to be idle or not actively using the computer for a scheduled task to be executed?
    No - if you do what I described it will work whether or not you are using the computer as long as it is switched on!
    It may not trigger exactly when you'd expect if other processes are occurring

    Agree with Paul about its not always easy to setup.
    It USED to be easy. Then MS added lots of additional options and it became difficult

    Make sure you have the Access program path correct (folder & file name) and the full application path set in the Arguments box
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by pbaldy View Post
    The script is pretty complicated, but I'll try.

    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "msaccess.exe C:\AccessAp\SendWebResEmail.accdb"

    I put the file in the same place the accdb is, but it doesn't really matter.
    Sorry, I'm not familiar Task Scheduler or scripts, but I'd presume I'd insert
    Set WshShell = WScript.CreateObject("WScript.Shell")
    into the Prgram/script textbox and the WshShell.Run... in the Add argument (optional): textbox? Is there somewhere I can test the script to debug where the breakdown may be in my error?

  9. #9
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    I don't know exactly how to enter the script into the Task Scheduler program, so I created a .bat file with the script . When I manually execute the .bat file, it works perfectly. However, when I put that .bat file into the Program/script textbox in the Task Scheduler and set a time to trigger it, the history shows that it ran, and just like my original post, nothing seems to have happened.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by LonghronJ View Post
    Sorry, I'm not familiar Task Scheduler or scripts, but I'd presume I'd insert into the Prgram/script textbox and the WshShell.Run... in the Add argument (optional): textbox? Is there somewhere I can test the script to debug where the breakdown may be in my error?
    No, those two lines are the entire vbs file. Create a file in Notepad with those two lines, adjusting for your file name/path. Save the file and then change the extension to vbs instead of txt. Double click on it, the Access file should run. Task Scheduler runs that file.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Is the location of your Access file a Trusted Location?

    See some relevant info here:
    https://social.msdn.microsoft.com/Fo...orum=accessdev
    https://social.msdn.microsoft.com/Fo...orum=accessdev

    Cheers,
    Vlad

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Could there be a failure to pass any command line arguments when using TS that are properly passed if you are manually open the db?
    Are you attempting to read any Command properties in vba that if missed, cause the form to not open and code is processed that simply closes the db?
    If so, you might want to try suspending all code temporarily and ensure nothing closes the db.
    I used TS successfully with accdb, but I put my command line switches in a shortcut.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by Micron View Post
    Could there be a failure to pass any command line arguments when using TS that are properly passed if you are manually open the db?
    Are you attempting to read any Command properties in vba that if missed, cause the form to not open and code is processed that simply closes the db?
    If so, you might want to try suspending all code temporarily and ensure nothing closes the db.
    I used TS successfully with accdb, but I put my command line switches in a shortcut.
    I have tried to pass the parameter with the exact .exe file name and the Access file name as well, as seen above. I've tried the scripts too. I know that when I manually launch the program, the AutoExec Macro opens a form, which has an On Open routine that inserts logging information to a table. After the file is launched, I can see in the aforementioned table filled with the user and the time of execution. The form then stays open. When using TS, the History indicates the Task Started...Task Completed. See Image.
    Click image for larger version. 

Name:	Scheduler 2018-04-13.jpg 
Views:	22 
Size:	69.0 KB 
ID:	33545

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Check out the various parts of the pdf I uploaded back in post 2.
    See if doing that instead solves the issue.

    I'd also advise including the approach suggested by micron in post 12 which I also use.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I'm guessing no Command property is being passed to the db because you repeat yourself and write about parameters instead. By asking I was trying to ascertain if you are using vba to close the db and avoid processing anything at all based on that property but I think not. While I understand the table isn't being written to what's not clear is if the db opens or not. If it does, it smells like a trusted zone issue as noted. Or maybe your credentials are not being used. There's a lot of info we can't know from the pictures.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 06-24-2016, 05:46 PM
  2. Windows Task Scheduler .Bat File Macro
    By mrmmickle1 in forum Access
    Replies: 26
    Last Post: 09-08-2015, 04:21 PM
  3. Tricky Relationships in a Task Scheduler
    By igglebop in forum Database Design
    Replies: 2
    Last Post: 05-03-2012, 10:27 AM
  4. Task Scheduler using Service Account
    By ExpertNovice in forum Access
    Replies: 2
    Last Post: 06-11-2010, 02:58 PM
  5. Database Scheduler
    By jgelpi16 in forum Access
    Replies: 4
    Last Post: 06-01-2010, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums