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.
7 2238
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 -
Function LoadNewDBS()
-
-
On Error GoTo Err_LoadNewDBS
-
Dim lngTime As Long
-
DoCmd.Close acForm, "fmnuMainMenu"
-
DoCmd.Hourglass True
-
lngTime = Timer: While Timer < lngTime + 1: DoEvents: Wend
-
SendKeys "%FOc:\Education\Translate.mdb~", False
-
-
Exit_LoadNewDBS:
-
Exit Function
-
Err_LoadNewDBS:
-
MsgBox Err.Description & " in LoadNewDBS"
-
Resume Exit_LoadNewDBS
-
End Function
-
Obviously file name and location can be passed as a parameter.
@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.
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.
@Lysander - You can definately Open another Access Database from within Access.
- Create a Public/Global Object Variable to represent an Access Application:
- Public appAccess As Access.Application
- 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:
- 'Substitute your External DB Path here
-
Const conPATH_TO_EXTERNAL_DB As String = "C:\Test\Northwind.mdb"
-
-
'Create a New Instance of Microsoft Access
-
Set appAccess = CreateObject("Access.Application")
-
-
appAccess.OpenCurrentDatabase conPATH_TO_EXTERNAL_DB
-
-
appAccess.DoCmd.OpenTable "Employees"
- Don't forget to Close the External DB, and do your Claen-Up chores when finished:
- 'Close the Opened Database (Northwind)
-
appAccess.CloseCurrentDatabase
-
Set appAccess = Nothing
- 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.
- Have you considered the use of Hyperlinks to Open the other DBs?
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.
@ADezii
Sendkeys method worked fine and they are all off to Chile and Argentia as happy bunnies:)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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".
|
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |