Results 1 to 14 of 14
  1. #1
    geraldk is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    49

    Running Macro as Schedule tak in Windows 7 Pro

    Hello,

    I have an error while running a macro in Access 2010. This macro will email me a report that I have completed in my database. When I run the macro while in Access it runs fine, but when I run it at a command prompt it errors out. The message comes up:

    No Current Record

    I have did some research on this error and found out that unattended Macros that run from Access will do this error, this was reported for Access 2007. I was hoping that Microsoft has fixed this error with a KB that I am missing.



    I am running another macro in the same database to email me a report and it runs fine for the command prompt.

    Here is the command line that I am running:

    start Msaccess.exe "c:\users\window7\desktop\Employee Database.accdb" /x mcoEmailPerformance

    Any help would be appreciate. Thank you in advance.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Have you tried using an autoexec macro so Access will launch the macro vs. having Windows start the macro? Then all you would need to do is open the accdb file.

  3. #3
    geraldk is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    49
    If I have the database open in autoexec how would I schedule the macro to run on a certain date (ie: Monday at 7:00am). Is there something in Access to run a macro? Or would I schedule something in schedule task?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I use task scheduler. One thing with task scheduler though, is it does not always seem to want to open Access files. The best approach seems to be to have task scheduler open a VBS or batch file. June7 pointed this out to me and she says she uses script files. Looks like you already have the makings of a batch file...

    Also, if you have a DB dedicated to the purpose, you can use a form at startup and avoid macros.

  5. #5
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    Hi there,
    I have a similar problem using Task Scheduler.
    It seems to be "stuck".
    It shows status as Running but nothing happens.

    Program/settings:
    "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"

    Add argument:
    \\File02\usfs\Crystal and Excel Reports - Phoenix\CrystalReports\Memberships\Memberships.acc db /x AutoRun

    Start in (optional): C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Office

    Anyone know what's wrong with the settings?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What is the x AutoRun switch for? What does it do? Maybe it is running in the background, not visible. Have you tried double clicking the Task?

  7. #7
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    That is the command-line switch to run a Macro in Access. Which is doing a RunCode of a Function. It does an output of a report.
    http://support.microsoft.com/kb/209207

    I ran the Task in the Task Scheduler and it shows the status as Running but nothing happens.

    I've tested the Macro and it works when I double-click on it.

    So I know it has something to do with the Task Scheduler side.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I gave up trying to get the Task Scheduler to open Access files. I use VB Script files. Here is some code that you can use to create a VBS file using your text editor. Just change the extension to .VBS

    Code:
    Option Explicit
    Dim oShell
    'open the Access file
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run """C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"" ""C:\FolderName\FileName.accdb"""
    With that, you can simply tell the Task Scheduler where the VB script file is (somewhere locally with rights) using the file picker provided by the task scheduler. I guess you can add your switch after the accdb extension too.

  9. #9
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    Ok thank you.

    It used to work great in Access 2003 with WinXP Pro with just a short-cut to the Macro ...
    and with the /x "macroname"
    not sure why it's not working in Access 2007-2010 with Win7 Pro

    Well, I'll try the VBS. Thank you

  10. #10
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    Hi ItsMe,
    So having never created a VBS before,
    When I clicked on VB it opened the MS VB for Applications Module1

    So I added:


    Dim oShell
    'open the Access file
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run """C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"" ""S:\Crystal and Excel Reports - Phoenix\CrystalReports\Memberships\Memberships.acc db /x AutoRun"""

    Under: Option Compare Database

    I get a Compile Error

    Invalid outside procedure

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I am not sure what "clicked on VB" means.

    If you want to create a script file, use the text editor of your choice. Maybe open Notepad and past the code I provided in a new Notepad TXT file. Save the TXT file. Rename the file extension to be .VBS.

    When you double click the new VBS file it should launch your Access app.

    Point Task Manager to open the new VBS file on a schedule.

  12. #12
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    Viola! I got it working!

    Change the name of the macro to AutoExec to utilize the built-in automated macro run

    then in Task Scheduler:
    In the Action section
    Select the Action: Start a program
    Under Settings
    Program/script: "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"
    Add arguments: "\\File02\usfs\Crystal and Excel Reports - Phoenix\CrystalReports\Memberships\Memberships.acc db"
    Start in: C:\Program Files (x86)\Microsoft Office

    it works perfect!
    just finished testing it.

    And of course to open Access and by pass the AutoExec hold down the Shift key until opened and the AutoExec will not run.
    \
    SOLVED

    Where is the Solved button?

  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Glad you got it working. Maybe I will take a look at what you did here to get task manager to open the accdb. Maybe it has to do with trust locations or....

    Anyway thread tools is where you can find options to mark a thread as solved. However, you did not start this thread so...

  14. #14
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    Definitely update the Trust Locations
    And Enable the Access Macros

    Yes, I realized that afterwards I didn't start this thread lol

    hopefully it solves it for the originator as it did for me

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

Similar Threads

  1. Replies: 4
    Last Post: 11-18-2013, 05:53 PM
  2. Detect which version of Windows is running
    By GraeagleBill in forum Programming
    Replies: 2
    Last Post: 12-31-2012, 05:07 PM
  3. Replies: 12
    Last Post: 02-09-2012, 02:27 PM
  4. maketable running without message windows
    By afshin in forum Queries
    Replies: 2
    Last Post: 01-10-2012, 04:44 AM
  5. Macro having issues when run on Windows Scheduler
    By faeren in forum Programming
    Replies: 4
    Last Post: 09-15-2011, 09:59 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