473,396 Members | 2,036 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,396 software developers and data experts.

Open one Access database from another

bard777
23
I am creating a utility database to use to update and maintenance other databases. One of them has an update process that uses 19 queries and as many linked tables. It works, but is complicated (and undocumented), so I would rather just have a button that opens that database.

I would prefer opening a specific form, but that is optional.

Here is some code (MSDN) I found that gets as far as opening the database, but once you click "Open" nothing happens.

Expand|Select|Wrap|Line Numbers
  1. Dim appAccess As Access.Application
  2.     Dim strDB as String
  3.  
  4.     ' Initialize string to database path.
  5.     Const strConPathToSamples = "C:\Program " _
  6.         & "Files\Microsoft Office\Office11\Samples\"
  7.  
  8.     strDB = strConPathToSamples & "Northwind.mdb"
  9.     ' Create new instance of Microsoft Access.
  10.     Set appAccess = _
  11.         CreateObject("Access.Application")
  12.     ' Open database in Microsoft Access window.
  13.     appAccess.OpenCurrentDatabase strDB
  14.     ' Open Orders form.
  15.     appAccess.DoCmd.OpenForm "Orders"
Any help would be great.

Thanks,
Bard
Jul 29 '08 #1
2 21073
janders468
112 Expert 100+
The following code is a function that returns the access application. To use this you would set an application object variable to the return value of this function:
Expand|Select|Wrap|Line Numbers
  1. Function OpenDB(DatabasePath As String) As Access.Application
  2.     Dim app As Access.Application
  3.     Set app = New Access.Application
  4.     app.OpenCurrentDatabase DatabasePath
  5.     Set OpenDB = app
  6. End Function
  7.  
For instance:
Expand|Select|Wrap|Line Numbers
  1. Sub Main()
  2.     Dim app As Access.Application
  3.     Set app = OpenDB("C:\SomeDatabaseOnYourComputerOrNetwork.mdb")
  4. End Sub
  5.  
You will then have access to the complete Access object model via the app variable. If you want to be able to see the application then you can set its visible property to true like so:
Expand|Select|Wrap|Line Numbers
  1. app.Visible = true
  2.  
That might get you started. Let me know if you have any questions.
Jul 29 '08 #2
NeoPa
32,556 Expert Mod 16PB
Application Automation may help as a reference.
Aug 5 '08 #3

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

Similar topics

10
by: vvenk | last post by:
Hello: When I tried to use an Access database, I get the following exception: Server Error in '/WebGrid' Application....
4
by: dennist685 | last post by:
Can't open my .mdb I was experimenting with opening an access database in IIS. For experimenting, I have an .mdb called HasbaraSample. In this case I copied it to the C:\Inetpub\wwwroot\Access...
0
by: Wayne | last post by:
Original Post: The following problem started on my PC about a week ago and I can't link it to any specific change. I'm using Access XP. If I have any database open and try to open any other...
4
by: Bugs | last post by:
Hi everyone. I am trying to open a database which works fine using Access 2003, but when trying to open it on another PC that has Access 2002 I get the following error "This database is...
4
by: Wayne | last post by:
How do I get rid of the generic Windows "Open File - Security Warning" that appears when I try to open a database that resides on another PC on my home network? This is not the annoying macro...
24
by: dancer | last post by:
Using ASP.net 1.1 and Microsoft Access. I received the following error message. Why? I have closed the Access file. I have another very small access file that opens with no trouble with the...
3
by: ConfusedMay | last post by:
Hi, I've created an access 2003 database that has a form with button called "open complaint database." This complaint database is also in access 2003. Here is my code to open the complaint...
5
by: Ian | last post by:
I am trying to: 1. Open a form on the external database 2. Enter a value in a text box on that form I have 1 above working OK using module form “The Access Web”, the module looks like this: ...
9
by: Martin | last post by:
Using ODBC in a PHP script, I'm trying to read an MS Access MDB file that resides on another computer on my LAN. I'm getting the error: Warning: odbc_connect() : SQL error: The Microsoft Jet...
12
by: godiva | last post by:
Hi, Last week one client had errors caused by another program which led the IT guys to wipe out and rebuild the hard drive on one particular computer. Prior to this happening, the people in this...
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.