Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Using Command() to retrieve parameter passed to DB

    I have a DB that is launched periodically via Windows Scheduled Task:



    Click image for larger version. 

Name:	000.jpg 
Views:	15 
Size:	37.9 KB 
ID:	48120

    The function run via Autoexec macro:
    Code:
    Public Function MedTimes()
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Dim strCmd As String
    
    
    strCmd = Command()
    MsgBox "parameter = " & strCmd
    
    
    (snip)
    
    
    
    
    End Function
    I'm not getting the command line value specified in the "Actions" property parameter. I don't see anything in the online help for command lines that seems to answer why the parameter isn't available from the Access Command function. Any ideas?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    It works when executed in the Run window but not when Task Scheduler runs the command. No idea why.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Me too elsewhere, which is why I'm clueless about why not with current OP?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    What purpose does this static parameter serve?
    What determines 'periodically'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    There will ultimately be 6 tasks scheduled, each having a different parameter. I could approach in a different way where I compare the time of day versus a table of times, but I'd rather not use hard-coded numbers in the app.

    Shouldn't I see some sort of reference to "function" when I look at the object browser?
    Click image for larger version. 

Name:	001.jpg 
Views:	13 
Size:	162.6 KB 
ID:	48121

  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
    I have this set up and running for a client, so I know it can work. It's possible I have the scheduled task running a VBS script instead of the actual db, with the command line there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Purely a syntax issue, the /Cmd 2 has to be outside of the parameter to Access:
    "c:\Program Files (86)\Microsoft Office \Office15\MSACCESS.EXE" "c:\Meds\MedTimes.accdb" /Cmd 2
    So, when one codes the Task Scheduler, the bold black above goes in the "Action" and both the blue and red go in the parameter box.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Finally got it to work. Had to delete task and rebuild.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 12
    Last Post: 12-19-2017, 10:09 AM
  2. Replies: 1
    Last Post: 10-08-2015, 10:59 AM
  3. Replies: 1
    Last Post: 05-06-2015, 01:23 PM
  4. How do I use a passed parameter in a Case statement
    By tarenja in forum Programming
    Replies: 7
    Last Post: 08-04-2013, 10:49 PM
  5. Replies: 1
    Last Post: 01-24-2012, 12:47 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