Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740

    Unanswered: run backend from frontend

    local backend (not shared) has some admin code that i need to run from time to time. the code needs to run from the BE and the FE needs to be closed whilst it is running.

    yes: i could persuade the user to close the FE and double-click BE, but ideally i would like to run the following from the FE:

    ' /// BEGIN DOES NOT WORK
    const pathBE = "c:\here\there\myBE.mde"
    Application.CloseCurrentDatabase
    Application.OpenCurrentDatabase pathBE
    ' /// END DOES NOT WORK

    any ideas ? ? ? ?

    izy
    Last edited by izyrider; 11-26-06 at 15:09. Reason: typo
    currently using SS 2008R2

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    why put i into the Scheduler of that computer.
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    thanks, but at first sight scheduler doesn't suit.

    the status change from no-admin-needed to admin-needed can occur fifteen seconds or one month from any given point in time: it is not neatly time-based.

    FE monitors the status and 'knows' if it has to run BE admin when it quits.

    i could put this admin stuff in the FE, but it sits so nicely in the BE and offers some convenience as well (with a compact on close).

    i suppose i could hack my way into scheduler and setup a onetime task to run at Now() plus 15 seconds, but it seems a bit of a fuss.

    i'm convinced i had some simple code that allowed First.MDx to run Second.MDx as First.MDx closed, but i can't find it in my library and my experimental thrashing around has so far failed.


    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    in the end it turned out to be stupidly simple:
    this seems to be working:
    Code:
        Dim dabs As DAO.Database
        Dim strShell As String
        Dim vntJunk As Variant
    
        '   ///     get location of the backend
        Set dabs = CurrentDb
        strShell = dabs.TableDefs("SomeTableInBackend").Connect
        strShell = Right$(strShell, Len(strShell) - (InStr(1, strShell, "DATABASE=") + 8))
        Set dabs = Nothing
        
        '   ///     get location of msaccess.exe and append location of backend
        strShell = SysCmd(acSysCmdAccessDir) & "msaccess.exe " & Chr$(34) & strShell & Chr$(34)
        
        MsgBox strShell & vbCrLf & Len(strShell)
    
        '   ///     shell to backend
        vntJunk = Shell(strShell, vbNormalFocus)
        
        '   ///     quit frontend
        DoCmd.Quit
    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Izy

    Looks like you sorted it so I won't bother testing my hypothesis
    However, should you not have instantiated a new Access instance (rather than using the current one with Application.DoStuff) and opened the BE with that and then closed the FE down? I think it would have had the same result as you got though.

    I think I had a similar issue when I played around with some code Wayne posted - I got the Wizard help assistant to friviously whiz around the screen without a (visible) access application but I needed a stub app to launch it and then kill itself.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You're relying on latency of spooling up the new thread to give the current instance time to close. Is that acceptable?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    fair comment Teddy.

    to be honest, i don't really know WHY the stupidly simple approach works so i can't answer your question - my instinct tells me that it should not work!

    i have a few test users having a go until production release 1st January, so i'm holding my breath and waiting to see what happens. so far (24 hours!!) so good tho. today will be interesting since i will meet a couple of the test users and can see how it flies on their machines

    ?? does it help that:
    -this app is 100% unbound so although the BE is 'linked' to the FE there is nothing 'open' on the BE at the time this stuff kicks in.
    -there is a significant chunk of startup code in the BE before anything happens tablewise on the BE.

    and Poots - an intermediate stub is my fallback plan.
    appFE starts appStub
    appFE quits
    appStub waits on a timer
    appStub starts appBE
    appStub quits
    ...it is not as pretty tho.

    izy

    AFTERTHOUGHT: Teddy's comment leads to an experiment that i will try later.
    ?? is is possible for appX to link to tables in appY whilst appY is actually running ??

    LATER_AFTERTHOUGHT
    forgot to mention, on startup the BE runs a bunch of code (to do with locking, references blah blah (i did mention that in outline)) and then it sits still running the timer.
    the admin routines kick in 8 seconds after the startup stuff completes
    Last edited by izyrider; 11-29-06 at 11:49.
    currently using SS 2008R2

Posting Permissions

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