Results 1 to 9 of 9
  1. #1
    jan.simpson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Location
    Brisbane Queensland Australia
    Posts
    5

    running Access function/code from external application


    Colleagues

    I have a complex Access F/E with SQLServer B/E.
    This ACCDB can send, via shell, commands to our GIS (Geographic Information System) activating search/find/display functions within the GIS. Data/parameters are sent via Access VBA and runs code within the GIS.


    I now want to do the reverse. Select map objects and send those details to the ACCDB to processing.

    I have created functions/code to process the data, but this requires a 'click' wtihin the ACCDB.


    In the past I have used the command line "MSACCESS.EXE dbname /x macroname" option to run code at start-up or for automation.
    Using the same technique for this application, a 'new' instance of ACCESS opens. This technique creates multiple instances of the F/End.

    Is there a way to send a command to ACCDB from an external source that will use the 'existing or currently running instance of ACCESS' if one exists, or if not, load a new instance? In the 'old days' with previous versions of ACCESS I thought there were some DDE type settings or commands.

    Any help and or snippets of code would be greatly appreciated!

    Thanks !

    Jan.Simpson

  2. #2
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    >>This technique creates multiple instances of the F/End.
    Is there a problem with this? You could have Access close when done processing.

    You may be able to put a timer in a form to look to see if processing needs to be done.

    I don't know of a way to use an existing instance.


  3. #3
    jan.simpson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Location
    Brisbane Queensland Australia
    Posts
    5
    thanks James. The problem is multiple instances of Access will be loaded and thus, confuse users.
    This ACCDB is used by 150+ users concurrently.
    Technically, the impact of multiple instances of ACCDB is minimal on SQLServer, but the user could have many instances of the same form open, leading to untidy UI.

    I suppose I could have a 'special form' to display data from the 'external data' link, but the preference would be for one instance of Access with one copy of the form opened. I've also toyed with Modality, but that makes things worse.

    The form must remain open while the user inspects the data/results of the data/query sent from the GIS, so a OnTimer closing would not work.

    I could have a difference FE exclusively for reading the data from the GIS and when the user closes the form, close ACCESS, but again, that's a bit 'tacky'.

    Thanks for your suggestion

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    With a split db, each user should run their own copy of the frontend, not the same file, so there are not multiple instances of the same file. User runs the copy from a location on their local workstation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Select map objects and send those details to the ACCDB to processing.
    Not sure of your process.... does the GIS save the data in a CSV file?


    I have a complex Access F/E with SQLServer B/E.
    So why bother with Access? Select any language (VB, C, C++, C#, ...) that can connect to SQL Server (SQLS), open the CSV file, process that raw data and insert the processed data into SQLS in the proper table(s) in the proper sequence.


    In the past I have used the command line "MSACCESS.EXE dbname /x macroname" option to run code at start-up or for automation.
    I know VB can be compiled into an executable which could be executed as above........

  6. #6
    jan.simpson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Location
    Brisbane Queensland Australia
    Posts
    5
    Thanks SSANFU
    I have restrictions on what tools can be used, and besides, THIS is an ACCESS Forum.

    I have resolved the issue using DDE. I initiate a DDE connection to the ACCDB and invoke objects from within the ACCDB

    here is a sample

    sMdb = "C:\SharedData\DATABASE\PLI_STAS_SqlServer.ACC DB"
    OnError Goto WakeUpAccess
    Start:
    hChan = DDEInitiate ("MSAccess", sMdb)
    DDEExecute hChan, "mi_lotplan" 'run this macro
    DDETerminate hChan
    Exit Sub

    WakeUpAccess:

    If Err()=697 Then
    nResult = ShellExecute (0, "open", sMdb, "", "", SHOWMINIMIZED)
    Resume Start 'try again
    End If


  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have restrictions on what tools can be used, and besides, THIS is an ACCESS Forum.
    I am well aware that this is an access forum. (I have over 4,000 posts here)

    I suggested a work-around since you didn't like the multiple instances of access being opened.

    Glad you were able to solve this.

    And thanks for posting your solution.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Did you see post 4?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    jan.simpson is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Oct 2015
    Location
    Brisbane Queensland Australia
    Posts
    5
    Yes, thanks June7. Each user has their own F/E.
    The issue was I was trying to use a shell with a command line to open Access and execute an macro (.. /X macroxxx) and thats what was causing a NEW copy of Access to load. The .. /X macroxxx function actually did the job correctly, but I 'thought' the OS and Access would recognise an existing instance was running.

    The DDE option (post #6) works perfectly, I just needed to find it!

    Thanks!


    JS

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

Similar Threads

  1. Code/function needed delete an external text file
    By Chris033115 in forum Programming
    Replies: 6
    Last Post: 03-31-2015, 02:09 PM
  2. Replies: 3
    Last Post: 05-03-2014, 09:22 PM
  3. Replies: 4
    Last Post: 04-01-2014, 03:56 PM
  4. Running code in function if checkbox is ticked
    By lewis1682 in forum Programming
    Replies: 7
    Last Post: 09-22-2013, 05:35 PM
  5. Replies: 1
    Last Post: 05-29-2013, 03:08 PM

Tags for this Thread

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