opening forms in different databases

monplankton

Registered User.
Local time
Today, 20:29
Joined
Sep 14, 2011
Messages
83
Hi I'm wanting to open a form from another database whilst I'm in another. I've seen that you can open a database but can you actually go straight to a particular form then return to where you were?
 
The easiest way to do this is to attach the other database as a library file to your active database.

Once this is done, you can call a function from the library database that opens the Form from there. You can call a function from the library database like any other function in your current database.

For example:
Assume that the following function is in your library database that opens a form from there:

Public Function LibraryForm()
DoCmd.OpenForm "myExternalForm", acViewNormal
End Function

When you call this function from a Command Button click event procedure the LibraryForm() Function will first check for the myExternalForm in it's native database, if found then opens it from there and appears in your current database window, as if the form is in the current database.

If myExternalForm is not found in the library database then the function will look for the form in the current database and if found then opens it from there.

Tip: We are using the Form/Report Wizard Interfaces in a similar manner from external databases.

If you woulld like to know more about Library Files visit the following Link:

MS-Access and Reference Library
 
Or you can just import the form into your db?
 
The library part I understand and I've added the other database in but I've never used the library function. How do I run this from a button on click() command?
 
Library function is any function that you write in the database that you have attached as a library database. In the above post I have given the sample code for opening a Form from the library database:
Code:
Public Function LibraryForm() 'here you can use any name you choose
       DoCmd.OpenForm "myExternalForm", acViewNormal
End Function

You should not have the same function name LibraryForm() in your current database.

Now, calling this function from a button-click event procedure is like calling any other function from your current database.

Assume that you have created a Command Button (with the name cmdOpen) on one of your Form to open the myExternalForm from the library database the sample code in the Command Button Click Event Procedure will look like the code below:

Code:
Private Sub cmdOpen_Click()
    LibraryForm
End Sub

When you click on the Command Button myExternalForm will open from the library database and will appear in your current database's window, as if it is opened from your current database.
 
however, where this can get confusing is the way the from is "bound" to data.

ie a form in your active database will be unbound, or bound to tables that are in your list.

if you open a form in another database, then you need to consider what you want to do with it, how the functionality is expected to work, and which data tables that form is bound to. And in my experience, this is not so easy to do. It is one thing having a library of functions that take common imputs and perform standard calcluations. It is a bit different trying to manipulate forms. It's a matter of trying all these things out - and in the end, you may find it easier to import stuff into your database.

eg - another issue with libraries, is how your database locates the library. You can set an absolute reference to them easily enough, but if you want the library database to be in a folder realtive to the current project, say - then it is not so easy to arrange this to work correctly on different machines. The only way seems to be to "force" the set up to be consistent on all machines. Another reason why I gave up trying to use library databases.
 
Thanks for all the replies. I've taken on board what you've all said and I'll let you know how I get on as I run the database over a server so not quite straight forward.
 

Users who are viewing this thread

Back
Top Bottom