473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Launching 1 Access app from another

344 Expert 100+
I did this, many years ago, using Access 2.0 but have forgotten how I did it.

What I want is for my user to click on their access icon which will launch the main application, say, ProjectCode, connected to ProjectData at the backend.

I want a button on the menu that, when they click on it, closes ProjectCode and opens, say TimesheetCode, connected to TimesheetData on the back end.

So far all I have been able to do is use Shell to start another instance of Access with the new code, which is not what I want. I need the use to be able to switch between Project and Timesheet (in fact several databases) without having multiple copies of Access running on the PC.

I know it can be done, or at least, it could be done, but like I said, I forget how I did it.

I am using Access 2003 for this.

TIA for any help.
Jul 8 '09 #1
7 2238
Lysander
344 Expert 100+
Finally found out how I used to do it. (Thank god I found an unsecured version of 10 year old code, as no way could I remember the secure password)

You need sendkeys, but you can't run it from the menu form, it needs to be in a global function so that you can close the form first. And it needs a delay. Can't remember why, but it works with a delay, it crashes without one

Anyway, here is the simple code
Expand|Select|Wrap|Line Numbers
  1. Function LoadNewDBS()
  2.  
  3.     On Error GoTo Err_LoadNewDBS
  4.     Dim lngTime As Long
  5.     DoCmd.Close acForm, "fmnuMainMenu"
  6.     DoCmd.Hourglass True
  7.     lngTime = Timer: While Timer < lngTime + 1: DoEvents: Wend
  8.     SendKeys "%FOc:\Education\Translate.mdb~", False
  9.  
  10. Exit_LoadNewDBS:
  11.     Exit Function
  12. Err_LoadNewDBS:
  13.    MsgBox Err.Description & " in LoadNewDBS"
  14.     Resume Exit_LoadNewDBS
  15. End Function
  16.  
Obviously file name and location can be passed as a parameter.
Jul 9 '09 #2
ADezii
8,834 Expert 8TB
@Lysander
A much better Option may be using Automation via the OpenCurrentDatabase() Method to open an existing Microsoft Access Database (.mdb) as the current database.
Jul 9 '09 #3
Lysander
344 Expert 100+
Thanks ADezii.

That looks a lot cleaner, if only I could get it to work. If I use OpenCurrentDatabase it says database is already open. If I use CloseCurrentDatabase first, nothing else runs.

Searching the web on this, it looks like I have to run this through Excel or something other than Access.

I'll keep looking, because it is a tidier idea. (Especially as sendkeys would only work on an English version of access. I'm sure in Portugues the File/Open option would be different words.
Jul 10 '09 #4
ADezii
8,834 Expert 8TB
@Lysander
  1. You can definately Open another Access Database from within Access.
  2. Create a Public/Global Object Variable to represent an Access Application:
    Expand|Select|Wrap|Line Numbers
    1. Public appAccess As Access.Application
  3. Execute the following code to Open the External Database within the Current Database. In this case, the code will Open the Employees Table in the Northwind Database residing in the C:\Test Folder:
    Expand|Select|Wrap|Line Numbers
    1. 'Substitute your External DB Path here
    2. Const conPATH_TO_EXTERNAL_DB As String = "C:\Test\Northwind.mdb"
    3.  
    4. 'Create a New Instance of Microsoft Access
    5. Set appAccess = CreateObject("Access.Application")
    6.  
    7. appAccess.OpenCurrentDatabase conPATH_TO_EXTERNAL_DB
    8.  
    9. appAccess.DoCmd.OpenTable "Employees"
  4. Don't forget to Close the External DB, and do your Claen-Up chores when finished:
    Expand|Select|Wrap|Line Numbers
    1. 'Close the  Opened Database (Northwind)
    2. appAccess.CloseCurrentDatabase
    3. Set appAccess = Nothing
  5. What you cannot do is 'Quit' the Current Database, then 'Open' the External Database in the same Code Context. You can, however, 'Close' a Form in the Current DB, then 'Open' the External DB.
  6. Have you considered the use of Hyperlinks to Open the other DBs?
Jul 10 '09 #5
Lysander
344 Expert 100+
Thanks.

What the above does is open a new instance of access with the new database.

To get rid of the calling database I added a docmd.quit which shut it down and looks ok, but not sure if I tieded up properly.

I can't use appAccss.closecurrentdatabase as the user would be using the new database for several hours, no idea when he would want to close it.
Jul 10 '09 #6
ADezii
8,834 Expert 8TB
@Lysander
Hope it all works out for you.
Jul 10 '09 #7
Lysander
344 Expert 100+
@ADezii
Sendkeys method worked fine and they are all off to Chile and Argentia as happy bunnies:)
Jul 27 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: MLH | last post by:
With Access 2.0, it was simple. 97 doesn't seem so obvious. Where do I start. I launched c:\windows\system32\Wrkgadm.exe and joined system.mdw in that same dir. Upon launching Access 97, I...
2
by: Tim Stevens | last post by:
Hello, This is the first time I have had to resort to posting on here, as Ive always been able to find a solution to my problems in the past by browsing postings by others. So, to start with I...
0
by: timandsuzi36 | last post by:
I have a WinForms App that is launching an Access 2003 db Reports program. I am using the System.Diagnostics.Process object to do so. I thought that I could pass my db connection string to Access...
6
by: sebastien | last post by:
Hi I have an asp.net application that use Session variables. What I want to do is to launch an second instance of this application by a link inside the first application. The problem is: when I...
1
by: John A. Bailo | last post by:
Excuse the novice aspects of this question, but: What techniques are available to me for launching one c# application ( console .exe) from another? For example, I know there is the Process and...
0
by: microb0x | last post by:
Is there any difference in the way an Access .mdb file is launched from directly double-clicking the file through windows explorer versus using code within another Access file to launch the...
3
by: rdemyan via AccessMonster.com | last post by:
One of my users had a corrupt front end that wouldn't open. My app is launched using a launching application (logon app). The logon app has a button for downloading a "fresh" copy of the front...
2
by: rlntemp-gng | last post by:
Re: Access 2003 / Outlook 2003 In my Access application there are three files that are created, 2 .xls and 1.txt While I have not integrated Outlook into an Access app, is there a way via...
4
by: MLH | last post by:
We have window for login/password and then error "Process is stopped by database core Microsoft Jet, another user changing data at the same time".
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.