Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2009
    Posts
    4

    Unanswered: Calling Access function or sub from Outlook

    Hello, this is my first time being here...

    I'm making a simple vb module in Outlook 2007 for recurrence event in Access 2007.

    Basically, my db has a sub to update its tables from different db, and I want Outlook's task function to run it everyday at a certain time.

    I got this code running, but this opens and brings up the actual db window for a split second, and closes it automatically

    Is there anyway to run this in the background so that i won't have to see the window at all??

    =========code I found (modified)=========

    Code:
    Dim appAccess As New Access.Application
    Dim objDBase As Object
    Const strDbPath = "\\Db_Server\DB\DbFile.mdb"
    
    Set objDBase = GetObject(strDbPath)
    Set appAccess = objDBase.parent
    
    appAccess****n  "CheckForUpdate"
    appAccess.Quit
    Set appAccess = Nothing
    ===========================

    this opens up the database, but results in error 13 Type Mismatch.
    "CheckForUpdate" - SUB name
    ****n = .r u n
    Is there a better way to schedule the sub for automated recurrence in background?

    Thank you very much for your attention in advance fellas...
    Last edited by msgking; 10-26-09 at 19:06.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Welcome to the forums

    To be honest, I've never tried scheduled running of an Access sub from Outlook before. Typically what I do is to create an mdb file with a form with the necessary code to run On Load, and then use the Task Scheduler to launch the mdb file when needed.

    You can use
    Code:
    docmd.echo false
    to turn the screen refresh off for the second you run the code if needed. Just make SURE to turn it back on (docmd.echo true), using Error Handling as needed to make sure it gets back on in the eventuality of an error.

    Cheers!
    Me.Geek = True

  3. #3
    Join Date
    Oct 2009
    Posts
    4
    ah, great. I actually found out that calling macros within Outlook Tasks became an another challenge.

    that's a much simpler solution. I just made a form and put a call subname in it OnLoad. I'll see how it's gonna work now. Since my db proc is a simple 'fetch the data from other db, calculate/analyze, and update the local table" deal, i'm sure it'll be just fine.

    Thanks a whole bunch!!

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    I forgot to mention, but you'll also need to set the form to automatically launch when the mdb file starts up.
    Me.Geek = True

  5. #5
    Join Date
    Oct 2009
    Posts
    4
    thnx for the reminder! i got that taken care of now. But....I got a new issue.

    Scheduled task somehow doesn't want to open the file....

    I noticed that the Access will boot up if i don't specify file, but as soon as i put file location, it just goes nothing.

    I made a .bat file and now it works...so many thanks to you!!!

    ....but....for the future reference i'd like to know why it does work when i use the below info. Anything wrong with this?

    "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE P:\testDb\test.accdb"

    starts in C:\Program Files\Microsoft Office\Office12\

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •