Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-11-2019, 04:19 AM   #1
lcarpay
Newly Registered User
Gold Supporter
 
Join Date: Oct 2017
Location: The Netherlands (Wijhe)
Posts: 10
Thanks: 5
Thanked 1 Time in 1 Post
lcarpay is on a distinguished road
Start an Access app from an external program?

hi experts, I have been searching but I can't find the solution. What I want is the following:
Provide a command-line option to an external program to:
  • check whether myAccessApp is already open
  • if so then activate myAccessApp and open e.g. a form with the provided external Id
  • if closed then open myAccessApp and open e.g. a form with the provided Id via /cmd or the autoexec

Anyone? thanks

lcarpay is offline   Reply With Quote
Old 07-11-2019, 04:23 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,429
Thanks: 58
Thanked 1,410 Times in 1,391 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Start an Access app from an external program?

Hi. We might be able to tell you how to use Access to manipulate an external program, but it’s a lot harder to tell you how to use an external program to manipulate Access, especially without knowing what the external program is. Can you give us more details please? Thanks.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 07-11-2019, 04:51 AM   #3
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,235
Thanks: 115
Thanked 3,073 Times in 2,791 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Start an Access app from an external program?

Just adding to the previous comments, it may be easier to use a batch file or vb script to run the Access app. Your external program could possibly be used to run those.

Or you could use a scheduled task for the purpose


Sent from my iPhone using Tapatalk

__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
Old 07-11-2019, 07:39 AM   #4
lcarpay
Newly Registered User
Gold Supporter
 
Join Date: Oct 2017
Location: The Netherlands (Wijhe)
Posts: 10
Thanks: 5
Thanked 1 Time in 1 Post
lcarpay is on a distinguished road
Re: Start an Access app from an external program?

Hi, the external applications in scope now are SalesForce and a custom made automatic PhoneResponse application. Starting myAccessApp when it is not active is not that hard but how to detect if myAccessApp is active?
lcarpay is offline   Reply With Quote
Old 07-11-2019, 07:44 AM   #5
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,429
Thanks: 58
Thanked 1,410 Times in 1,391 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Start an Access app from an external program?

Quote:
Originally Posted by lcarpay View Post
Hi, the external applications in scope now are SalesForce and a custom made automatic PhoneResponse application. Starting myAccessApp when it is not active is not that hard but how to detect if myAccessApp is active?
I am not familiar with how those other apps interact with Access. What methods are available to manipulate other apps from within them? For example, do they have VBA? If not, what exactly do you use to start your Access App from SalesForce or PhoneResponse?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 07-11-2019, 08:51 AM   #6
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,235
Thanks: 115
Thanked 3,073 Times in 2,791 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: Start an Access app from an external program?

You can check if your Access app is running by looking for the existence of the lock LACCDB file. Itís not quite 100% effective as occasionally it doesnít get deleted when apps close. Also if your app is opened in exclusive mode no lock file is created.


Sent from my iPhone using Tapatalk
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
Old 07-11-2019, 12:02 PM   #7
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,507
Thanks: 439
Thanked 838 Times in 809 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: Start an Access app from an external program?

I use this vba script to kill a process. You could probably adapt it ?

Code:
' ProcessKillLocal.vbs
' Sample VBScript to kill a program
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.7 - December 2010
' ------------------------ -------------------------------' 
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill 
strComputer = "."
strProcessKill = "'msaccess.exe'" 

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _ 
& strComputer & "\root\cimv2") 

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
'Next 
WSCript.Echo "Just killed process " & strProcessKill _
& " on " & strComputer

Next
WScript.Quit 
' End of WMI Example of a Kill Process

__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 07-11-2019, 12:22 PM   #8
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,569
Thanks: 68
Thanked 2,745 Times in 2,630 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Start an Access app from an external program?

you can use api to get ms access window handle number if the app is running. 0 if not running:
Code:
Option Explicit

' Module Name: ModFindWindowLike
' (c) 2005 Wayne Phillips (http://www.everythingaccess.com)
' Written 02/06/2005
'
' mODIFIED bY aRNELgP FOR x64 aCCESS
'
                   
#If VBA7 Then
    #If Win64 Then
        Private Declare PtrSafe Function EnumWindows Lib "user32" (ByVal lpEnumFunc As LongPtr, ByVal lParam As LongPtr) As Long
        Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As LongPtr, ByVal lpString As String, ByVal cch As Long) As Long
        'Could use global variables instead, but this is nicer.
        'Custom structure for passing in the parameters in/out of the hook enumeration function
        'Could use global variables instead, but this is nicer.
        Private Type FindWindowParameters
        
            strTitle As String  'INPUT
            hwnd As LongPtr     'OUTPUT
        
        End Type
    #Else
        Private Declare PtrSafe Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
        Private Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
        'Could use global variables instead, but this is nicer.
        'Custom structure for passing in the parameters in/out of the hook enumeration function
        'Could use global variables instead, but this is nicer.
        Private Type FindWindowParameters
        
            strTitle As String  'INPUT
            hwnd As Long         'OUTPUT
        
        End Type
    #End If
#Else
                    
        Private Declare Function EnumWindows Lib "user32" _
           (ByVal lpEnumFunc As Long, _
            ByVal lParam As Long) As Long
        
        Private Declare Function GetWindowText Lib "user32" _
            Alias "GetWindowTextA" _
           (ByVal hwnd As Long, _
            ByVal lpString As String, _
            ByVal cch As Long) As Long
        'Could use global variables instead, but this is nicer.
        'Custom structure for passing in the parameters in/out of the hook enumeration function
        'Could use global variables instead, but this is nicer.
        Private Type FindWindowParameters
        
            strTitle As String  'INPUT
            hwnd As Long        'OUTPUT
        
        End Type
#End If


#If VBA7 And Win64 Then
Public Function FnFindWindowLike(strWindowTitle As String) As LongPtr

#Else
Public Function FnFindWindowLike(strWindowTitle As String) As Long
#End If
    
    'We'll pass a custom structure in as the parameter to store our result...
    Dim Parameters As FindWindowParameters
    Parameters.strTitle = UCase(strWindowTitle) ' Input parameter
    

#If VBA7 And Win64 Then
    Call EnumWindows(AddressOf EnumWindowProc, VarPtr(Parameters))
#Else
    Call EnumWindows(AddressOf EnumWindowProc, VarPtr(Parameters))
#End If
    FnFindWindowLike = Parameters.hwnd
    
End Function

#If VBA7 And Win64 Then
Private Function EnumWindowProc(ByVal hwnd As LongPtr, _
                               lParam As FindWindowParameters) As LongPtr
#Else
Private Function EnumWindowProc(ByVal hwnd As Long, _
                               lParam As FindWindowParameters) As Long
#End If
   Dim strWindowTitle As String

   strWindowTitle = Space(260)
   Call GetWindowText(hwnd, strWindowTitle, 260)
   strWindowTitle = UCase(TrimNull(strWindowTitle)) ' Remove extra null terminator
                                          
   If strWindowTitle Like lParam.strTitle Then
   
        lParam.hwnd = hwnd 'Store the result for later.
        EnumWindowProc = 0 'This will stop enumerating more windows
   
   Else

        EnumWindowProc = 1

   End If
                           
End Function

Private Function TrimNull(strNullTerminatedString As String)

    Dim lngPos As Long

    'Remove unnecessary null terminator
    
    lngPos = InStr(strNullTerminatedString, Chr$(0))
   
    If lngPos Then
        TrimNull = Left$(strNullTerminatedString, lngPos - 1)
    Else
        TrimNull = strNullTerminatedString
    End If
   Debug.Print TrimNull
End Function


Private Sub test()
#If VBA7 And Win64 Then
    Dim h As LongPtr
#Else
    Dim h As Long
#End If
    Dim i As Integer
    Dim wa As Word.Application
    Dim wd As Word.Document
    
    Set wa = New Word.Application
    Set wd = wa.Documents.Add
    wa.Visible = True
    'wa.Activate
    h = FnFindWindowLike("*word*")
    Debug.Print h
    Call MouseToWinHandle(h)
    For i = 1 To 5000
        DoEvents
    Next i
    Call MouseToForm
    wa.Quit False
End Sub
sample from vbe immediate window:

debug.print fnWindowLike("*access*")
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
Gasman (07-11-2019)
Old 07-11-2019, 12:35 PM   #9
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,569
Thanks: 68
Thanked 2,745 Times in 2,630 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Start an Access app from an external program?

here is another discussion on activating access if already running:

https://access-programmers.co.uk/for...d.php?t=288321
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
The Following User Says Thank You to arnelgp For This Useful Post:
lcarpay (07-11-2019)
Old 07-11-2019, 08:07 PM   #10
lcarpay
Newly Registered User
Gold Supporter
 
Join Date: Oct 2017
Location: The Netherlands (Wijhe)
Posts: 10
Thanks: 5
Thanked 1 Time in 1 Post
lcarpay is on a distinguished road
Re: Start an Access app from an external program?

Thanks you all. Enough reactions to get me going. I have have to investigate the offered solutions (and hints of solution directions). The result will be posted.

lcarpay is offline   Reply With Quote
Reply

Tags
activate access , command line

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Close external program TylerTand Modules & VBA 3 07-25-2008 11:54 AM
External Program CanWest Modules & VBA 10 10-18-2007 04:41 AM
How do I open an external program from Access tosspot Modules & VBA 9 07-06-2007 07:03 AM
Run external program and get output mlh407 Modules & VBA 2 07-10-2006 10:50 AM
how to run an external program and put its output in access tuxA Modules & VBA 2 06-09-2005 08:22 AM




All times are GMT -8. The time now is 03:09 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World