Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Jan 2005
    Posts
    12

    Exclamation Unanswered: How to determine which MS Access database is running in an MSACCESS process.

    How can I determine which MS Access database is running in an MSACCESS process?

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    CurrentDB.Name will return the path\name of the current database.

    Is that what you're looking for?
    Inspiration Through Fermentation

  3. #3
    Join Date
    Jan 2005
    Posts
    12
    I have retrieved all the processes that are running on the computer. Once of them is MSACCESS. But it doesn't tell me which database is running under that process. Is there a way to determine which database is open under that process?

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    So, are you saying that when you look at the Processes tab in your task manager, you can see that MSACCESS.EXE is running, but you can't find any windows with Access running?
    Inspiration Through Fermentation

  5. #5
    Join Date
    Jan 2005
    Posts
    12
    Yes. I can see it running under the processes tab. I want to know if there is a way to determine which database that process (MSACCESS) is running.

  6. #6
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    *scratches head*

    Does the process show when you first boot up the computer?
    Inspiration Through Fermentation

  7. #7
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Quote Originally Posted by trishmiddleton
    Yes. I can see it running under the processes tab. I want to know if there is a way to determine which database that process (MSACCESS) is running.
    I'm sorry, i dont think you can, to Windows i presume all it sees is the program it is running which is the Access shell

  8. #8
    Join Date
    Jan 2005
    Posts
    12
    Once the program is running I open the task manager and all I see is MSACCESS.

    I'm using VB.NET to grab the process but it doesn't tell me which database is actually running inside that process. I was just curious if someone knew of a way to find out which database is open inside that process.

    I've looped through the modules and the threads on the process and it doesn't tell me anything. I thought maybe someone might know a way to find out.

  9. #9
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    What is the purpose for the program?

    Maybe there is some other solution to your problem not using the processes?

  10. #10
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    You may want to research some here

    http://www.mvps.org/access/api/index.html

    All kinds of cool API tricks, one of them may answer your question.
    Inspiration Through Fermentation

  11. #11
    Join Date
    Jan 2005
    Posts
    12
    I'm checking to see if the application is already running. I don't want to start it if it is already running. At this point, I can only tell that MSACCESS is running. This is being done by a VB.NET application.

  12. #12
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    You dont actually have to check the processes then, there was some script i wrote in VB6, i have it on my local comp, it is at work, it checked if an access database was already open and then closed it to make some updates and then re opened it, you could apply the same to say if already open then dont re open.

    You arnt in luck unfortuantely, my VPN is down at the moment and cant access my work server!

    I will see if i can find the code on the internet because thats where i found it in the first place.

    Give me 15 mins

  13. #13
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Right, this is the code for vb6, ive only just started using .NET myself so i dont know how to call the API from .NET but here is the code to find a window and close it

    Use the FindWindow API call to locate the Window handle.

    'declare
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    'now actually find the window
    dim hWnd as long
    hWindow = FindWindow(vbNullString, "Some Window Title")


    Then tell the window to close. There are two nicely (akin to pressing Alt-F4) and angrily (basically killing it)

    'declare
    Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    Public Const WM_QUIT = &H12
    Public Const WM_CLOSE = &H10

    'killing it softly
    PostMessage hWnd, WM_CLOSE, 0, 0&

    'killing it hard
    PostMessage hWnd, WM_QUIT, 0, 0&

    I hope this helps, you could actually put this code into the on open of the first form in the access database you are opening and do a loop to count the number of the program open and then close one less than the required amount just in case they open the program quickly because it doesnt assign the title of the access database for a few seconds and could give the user time to open a few before the code could take effect.

  14. #14
    Join Date
    Jan 2005
    Posts
    12
    I don't want to close it. I've been given this access application and I'm to get it running on a different server. It's been horribly programmed. It shuts itself down every once in a while because of what it calls "memory leaks". I've written a VB.NET application that all it does is check to make sure the darn thing is running. Every minute it checks the processes and if it doesn't see MSACCESS that it starts it up again. If for some reason someone starts another MS Access Application I would like a way to check to see if the one I need running is still running.

  15. #15
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    Im not saying close it, that was sample code, im saying that if you use that code then you can adapt that code to find the window and then do whatever you want to do with the program, you do a loop to find the window, if the window is open then dont open another, if it isnt open then open it.

    I found the code in .NET, im just testing it in visual studio, if i can get it working ill post it.

Posting Permissions

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