Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080

    DB return codes?


    If DB1 app Shells to a DB2 app, is there a way for DB2 app to pass back a return code to the DB1 app? Like when DB2 app issues a DoCmd.Quit.

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Interesting question. Maybe this https://www.tek-tips.com/viewthread.cfm?qid=682230

    I suppose the quit code of the called db could write to a file as an alternative. Then db1 would read the file value.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080
    I had thought about a file or even a transient file name plus writing and reading off the clipboard. I don't like using the clipboard unless I remain totally within the app itself so unless someone comes up with a better idea I'll likely go with a transient file name that can quickly be examined with a DIR function in a folder exclusive to both apps.
    Thanks,
    Bill

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Hi Bill
    This is at least the third time I've answered similar questions in recent months
    Yes its possible - whether its desirable is another matter

    See this link for some code that you should be able to adapt for your needs fairly easily
    https://www.access-programmers.co.uk...78&postcount=5
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080
    Hi Colin,
    Not sure what your word of caution means:
    whether its desirable is another matter
    At issue is not so much a question of how to launch a macro in another DB but rather how to get a return code back when the macro ends (Quits).

    As to your "RunExternalDatabase" function, my understanding is that I can use Shell followed by a "DoCmd.DoEvents" that will pause the code until Shell finishes but I've not yet found the VBA API function that can be employed to receive a return code being passed back from the Shelled app.

    Bill

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Hi Bill

    The example code was supplied for two different forum members who each wanted to:
    a) open an external database, run a macro and close the 2nd database
    b) close the current database

    As I said in the linked post,
    I never understood at the time why the OP didn't just link the external database tables & run the macro or code directly but they didn't want to do that
    Hence my comment "whether its desirable is another matter"

    As I'm not sure exactly what you want to do or why, I've no idea whether its a sensible idea or not
    But the code I posted definitely works and I think, could be adapted for your purposes

    HTH
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Not clear to me if you want the result of a procedure to be passed back or a value that indicates the shell process has terminated. If the former, I can only see this as being a write to a file solution. If the latter, I found api functions are identified in the link I have you, so I'm confused (again).

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080
    just link the external database tables & run the macro or code
    1) I did not know that one could link to a macro in another DB, say DB2.
    2) DB2 has links to privileged tables in yet a different DB resident on an NAS.
    3) If one can in fact link and run a macro in another DB, there's still the question of
    obtaining a return code issued by the macro on DB2.

    I fear that what's required here could become un-necessarily convoluted. The macro in DB2 normally executes apart from DB1 or it could otherwise link to a table in DB1 and store return code(s) there. On the latter point, can the DB2 macro make a friendly inquiry of a linked table that might not be available?

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080
    Ah! Not interested in the return code from Shell, only the a return code from the macro that ran from a separate DB. See my post to Colin regarding a friendly inquiry of availability of a linked table. Baring that, I will write a transient txt file to a dedicated folder with the return code as its name and fetch the file name with a Dir function.
    Bill

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    You probably would want to verify that a file with that same name doesn't exist and delete after reading unless you wish to accumulate them. You would think deleting would mean it's not possible for the file to exist on subsequent executions but the Kill process could fail.

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080
    delete after reading
    Yes, exactly.
    Thanks

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    I'm still not clear after reading several posts what you want to happen.
    Micron's last answer has unfortunately confused me further.

    Let me ask the same question as I did to the two previous people who wanted DB1 to perform an action in DB2 which then needed to do something else in DB1.
    Why not just run everything from DB1?
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  13. #13
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,080
    Sorry about the confusion Colin. The issue IS NOT how does one open an app in a different DB. The problem I was having had to do with obtaining return codes. I.e., how can the "launchee" communicate to the "launcher" how things turned out when the "launchee" quits?

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    That's roughly what I thought you meant from the start but I'm still unclear why it can't all be done from the launcher app
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  15. #15
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Colin, I read the code and what I'm not seeing is how the result of a process (e.g. ABC123) gets passed back to the calling db. While I think that represents the goal, it sure would help to have an example of what the return value is and how it's derived.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 04-04-2017, 02:50 AM
  2. Zip codes
    By joecamel9166 in forum Access
    Replies: 4
    Last Post: 04-01-2016, 02:12 PM
  3. Sql codes
    By hawke in forum Programming
    Replies: 1
    Last Post: 01-14-2015, 11:53 AM
  4. Access Codes
    By Probie in forum Code Repository
    Replies: 3
    Last Post: 06-04-2013, 01:18 PM
  5. Zip Codes
    By Laurie B. in forum Access
    Replies: 6
    Last Post: 02-25-2011, 02:38 PM

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