Results 1 to 8 of 8
  1. #1
    runk is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Location
    FL
    Posts
    4

    How to - write vba module / macro to import multiple DoCmd.RunSavedImportExport cmds


    Was trying to automate imports which occur daily
    wrote a module called dailyimports (tested it runs from design view without error)- but when creating a macro to call this module, selecting new macro - action runcode - clicking function name - dbname - dailyimports -ok
    macro is empty???

    code
    Sub DailyImports ()
    '// Automates Daily Imports
    "DoCmd.RunSavedImportExport Import-ActiveDirectory_LastLogon"
    "DoCmd.RunSavedImportExport Import-EmployeeBadges"
    "DoCmd.RunSavedImportExport Import-AD_Accounts"
    "DoCmd.RunSavedImportExport Import-AD_Group_Membership"
    End Sub
    /code

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If memory serves, you can only run a function from there. Try changing to:

    Public Function DailyImports ()
    '// Automates Daily Imports
    "DoCmd.RunSavedImportExport Import-ActiveDirectory_LastLogon"
    "DoCmd.RunSavedImportExport Import-EmployeeBadges"
    "DoCmd.RunSavedImportExport Import-AD_Accounts"
    "DoCmd.RunSavedImportExport Import-AD_Group_Membership"
    End Function
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    runk is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Location
    FL
    Posts
    4
    Tried setting it up using expression builder Click image for larger version. 

Name:	macroAccess.JPG 
Views:	9 
Size:	21.9 KB 
ID:	11315 Click image for larger version. 

Name:	err.JPG 
Views:	9 
Size:	10.7 KB 
ID:	11316 error Click image for larger version. 

Name:	err2.JPG 
Views:	8 
Size:	20.0 KB 
ID:	11317
    Any ideas?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Is it a public function in a standard module? And make sure the module doesn't have the same name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    runk is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Location
    FL
    Posts
    4
    Yes the module has the name
    DailyImports
    it contains
    Public Function DailyImports ()
    '// Automates Daily Imports
    DoCmd.RunSavedImportExport "Import-ActiveDirectory_LastLogon"
    DoCmd.RunSavedImportExport "Import-EmployeeBadges"
    DoCmd.RunSavedImportExport "Import-AD_Accounts"
    DoCmd.RunSavedImportExport "Import-AD_Group_Membership"
    End Function

    VB runs fine from within Design view

  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
    Let me add emphasis:

    Quote Originally Posted by pbaldy View Post
    And make sure the module doesn't have the same name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    runk is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2013
    Location
    FL
    Posts
    4
    Thanks, Macro, Module, and Function all named different and working - Thanks again

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 2
    Last Post: 05-16-2012, 07:46 AM
  2. Import multiple Text files with a Macro
    By ArchMap in forum Access
    Replies: 3
    Last Post: 07-01-2011, 04:56 PM
  3. DoCmd.RunSavedImportExport file name
    By svcghost in forum Import/Export Data
    Replies: 6
    Last Post: 02-08-2011, 08:05 AM
  4. Creating Macro from Module
    By Harley Guy in forum Modules
    Replies: 1
    Last Post: 11-08-2010, 07:44 AM
  5. need help with import Module
    By marubal21 in forum Modules
    Replies: 1
    Last Post: 07-22-2010, 12:23 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