Results 1 to 12 of 12
  1. #1
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22

    Unhappy Trying to open other db's from another


    Pleeeeease someone help me! I have four access 2000 databases. Let's call them eenie, meenie, miney, and moe. I currently have four shortcuts on my desktop that opens each. I want to create a generic database that opens a form which has four command buttons named "eenie" "meenie" "miney" and "moe", that will launch each application. I don't need the buttons to open a specific form, i just need it to perform the same function as the windows desktop shortcut. I've tried several ways, and the problem I keep having is when I finally get a command button to work, it will open multiple instances of each db when clicked again and again. I want to be able to keep each db up and running, and when the command button is clicked, it will just bring the running db to the front and not open another instance of it. SURELY this isn't impossible!

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    I have an app that allows the users to open anyone of several mdb's and when launched it brings that mdb to the forefront and keeps the focus until the app is closed then the user is returned to the original mdb. Do not have it with me today but will get the code to you on Monday if that ok.

    David

  3. #3
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22
    Yes yes yes please! I would be soooo greatful!

  4. #4
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22
    David, the deal is, I need to be able to keep the four mdb's up and running and switch back and forth between them. Will your app allow this?

  5. #5
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Code:
     
    Public Function Toolkits(Letter As String)
    Dim stAppname As String, Kit As String
    Dim PathName As String
    PathName = " C:\AccessSystems\"
    Kit = "X"
    Select Case Letter
        Case "S": Kit = "Stores2000.mde"
        Case "E": Kit = "Extrusion2000.MDE"
        'Case "D": Kit = "MasterDirectors.MDE"
        Case "I": Kit = "Inspection2000.mde"
        Case "F": Kit = "Finishing2000.mde"
        Case "Q"
        If Dir("C:\AccessSystems\Sales2000.mde") = "" Then
            FileCopy "V:\Toolkits\Access 2000 Toolkits\Sales2000.mde", "C:\AccessSystems\Sales2000.mde"
        End If
        Kit = "Sales2000.MDE"
        Case "W": Kit = "Moulding2000.MDE"
        Case "T": Kit = "Tool2000.MDE"
       ' Case "Y": Kit = "MasterEnquiry.mde"
        Case "Z": Call msgbox("Please launch the download from the Development PC as it is the latest version and will run more efficiently", vbCritical + vbOKOnly, "Warning")
        
        
    End Select
    If Kit <> "X" Then
        stAppname = "msaccess.exe" & PathName & Kit
        Call Shell(stAppname, 1)
    End If
    Toolkits = Kit
    End Function
    In the above example I had a custom menu that listed the applications that the user could open. These were in a shared location on the server.

    The command line on the menu item was =ToolKits("x") where X is the parameter sent to the public funcion ToolKits().

    As you can see in the code the fisrt thing was to detect if the file existed in the known location then it used FileCopy to copy it from the server to the local machine. This was to reduce the load on the network as Access would have to drag the app across the network along with the data.

    I then used Shell to open up the app. The app also appears in the task bar on the desktop so this allows me to tab back to the master mdb and if required I could open up a further mdb.

    Hope this helps

    David

  6. #6
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22
    Mr. David, no disrespect meant, but I have no idea what this code is you've posted for me. I've tried to use it, but I'm evidently not understanding something. I still wonder if I'm making myself clear on what I'm trying to accomplish. I need a command button to open a .mdb! It needs to work JUST like a desktop shortcut. If the .mdb is running in the background, I need it to bring it to the front instead of opening another instance of it. The files i'm trying to open are Check.mdb, Title.mdb, CC.mdb, and Daily.mdb. Can you or someone write code that I can use behind a (4) command buttons to open each of these? (actually just for one, of course i can duplicate) i want my master form to stay open and not close when these are clicked.

  7. #7
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    In the main declarations section of the form you first need to declare a couple of variables

    Code:
     
    Dim strPath As String
    Dim strMDB As String
    Dim strAppName As Sting
    In the OnLoad event of the form set the location of the mdb's
    Code:
    strPath = "<<PathToMdbLocation>>"
    Example:
    strPath = "C:\Program Files\Databases\"


    On the OnClick event of a given command button type in the following

    Code:
    strMDB = "<<NameOfMDB>>"
    Example:
    strMDB = "Check.Mdb"

    Code:
     
        stAppname = "msaccess.exe" & strPath & strMDB
        Call Shell(stAppname, 1)
    Follow these steps and you should be ok

    David

  8. #8
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22
    ok guys, I told y'all I'm new here. What on earth do you mean when you say "in the main declarations section"? I have searched and searched and find no such explanation

  9. #9
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22
    i've tried, and tried to make this work, all i get is "file not found", and David, is your "r" not working? read your post, it says Dim strAppname as "sting", and strAppname in places and stAppname in others. just curious

  10. #10
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    It'snot my r that is not working it's my finger. Compound this with my dislexia and leaving my glassess at home, I consider the reply was ok.

    Go to the design of the form then right click on the top left hand corner on the little box and select build event. You may see the words Option Compare Database. You will also see two combo boxes in the left choose (general)
    underneath and before and sub routines are declared is known as the main declarations section. This is where you need to delclare your variables.

    David

  11. #11
    jlm722 is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    22
    :0). Lol ok. Thanks Mr. David. Now It works, and opens my file, but still repeated clicks of the command button are opening multiple instances of the db. I want the command button to bring the open db to the front active window, and not open another instance. What is the trick for that?

  12. #12
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    So what you are saying is Yes to opening the first instance of a known mdb but No to second or subsequent instances of the same mdb.

    To do this you will need to include a bit of admin.

    Create a table in the main BE that holds the names of the known mdb's include in this table a field (boolean) named IsOpen and set the default value to No. Now when the user clicks on the command button from the master mdb it performs a search on the admin table to see if the value of IsOpen = False if it is it then it updates the field to True then proceeds to open the database in question.

    Each of the child mdb's will have a link to the admin table in the BE. When this child mdb closes it peforms an update on the admin table to reset the IsOpen field to False.

    So in conclusion the master will only allow the child to open if the IsOpen Field = False.

    Taking this one step further are there going to be more that one person using the master at any one time? If so you will need rethink your strategy by including the computer name into the admin table to check if the user of that machine has got the child mdb open or not.

    David

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

Similar Threads

  1. Replies: 1
    Last Post: 06-04-2009, 07:43 AM
  2. Can not open File already in use.
    By Wrangler in forum Access
    Replies: 1
    Last Post: 03-04-2009, 09:50 PM
  3. Form will not open
    By dserbanescu in forum Forms
    Replies: 0
    Last Post: 01-09-2008, 09:48 AM
  4. Replies: 3
    Last Post: 02-02-2006, 07:39 PM
  5. 'On Open' Property
    By emilylu3 in forum Forms
    Replies: 1
    Last Post: 12-08-2005, 02:28 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