Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run code in db1 from db2

    I hope you can help. I am under pressure to get this task accomplished today.

    I have to be able to run code in a separate db from another db and can't figure out how to go about it.

    Here's the deal:

    I have a db (db1) that has some data in it that gets updated daily, providing somebody opens the db. I have code in a startup form that handles the procedure.

    I have a second db (db2) that also needs access to the data. When someone open db2, I want to connect to db1 and run the code to force the update if it hasn't already been updated. I have all the updating and checking logic already implemented. I have code running in db2 that connects to db1 and checks the date of the last update and determines if an update is necessary. I don't know how to force the procedure to run in db1 from db2. I've tried a startup form in db1 - apparently startup forms only run when the db is opened under user control. I tried an autoexec macro in db1 with the same results - only runs when the db is opened under user control.

    So, bottom line here, how can I force code in db1 to execute under program control from db2?

    I sure hope you can help.

    Thanks for whatever time and consideration you can provide.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run code in db1 from db2

    Use Automation to open db1 in a second instance of Access and run the necessary code. Example:

    Dim appAcc As New Access.Application
    appAcc.OpenCurrentDatabase "serverfolderdb1.mdb"
    appAcc.Quit acQuitSaveNone
    Set appAcc = Nothing

    An AutoExec macro in db1 will be run, and a startup form will be opened, if present.

  3. #3
    Star Lounger
    Join Date
    Jun 2004
    Location
    Lambertville, New Jersey, USA
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run code in db1 from db2

    Worked like a charm!
    Thank you so much.
    I had this same question posted on another board for 3 days.
    I got a lame ambigious response from the people running the board.
    When I responded back asking for some clarification, they ignored me. I even sent them an email which they also ignored.
    You guys are great. Thanks again.
    Lance

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Run code in db1 from db2

    You're welcome. This is a very pleasant discussion board.

Posting Permissions

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