Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a form from a different database

Status
Not open for further replies.

patyavila

Technical User
Apr 29, 2004
28
US
Do anyone knows if its possible to run a form that resides on a different mdb?
Will apreciate any help. Have two different databases that share some tables but are needed to keep apart. There are a couple of procedures that need to be executed on DB1 but results will be used on DB2.

Thnx
Patricia
 
No, I don't think so.

You are better off just importing the form from the other database. That would be my approach.

Gary
gwinn7
 
If the form loads on tables located on other databse, you could export only 1 table to a text reference coma seperated and use it to refer with SQL on your Form....
 
Thank you both!

Import? as far as I know one can export. Anyway, this will mean having two objects that, when modified, will need to be modified in both sides. In this case I have some variables defined as global on dbsource but not in dbtarget so will have to change code on the exported form, just to imagine Change Control makes me doubtful about this being the best approach for us.

CSV, in my case, is not an option but appreciate your colaboration. (-:
 
How are ya patyavila . . .

Yes you can but you'll need code in the external db to open the form as it can't be done directly. [blue]Basically you'll be setting the external db as a library reference in the current db.[/blue] What this does is make all modules in the modules windows available along with their subs and functions. As a library these are now available to you for direct use. You can even see them in the Object Browser! [blue]Just be aware of functions & subs in both db's which may have the same name.[/blue]

[purple]Note: the following doesn't take into account any conflicts that may arise from the shared tables or multiuser operations of either db . . . if any![/purple]
[ol][li] In a module in the modules window of the [blue]external db[/blue] (the one that holds the form), copy/paste the following routine:
Code:
[blue]Public Sub OpenExtFrm(frmName As String)
   DoCmd.OpenForm frmName
End Sub[/blue]
[/li]
[li]Save & Close the external db.[/li]
[li]Open the [blue]calling db[/blue] and navigate your way to the [blue]VBE editor[/blue].[/li]
[li]Then [blue]Tools[/blue] - [blue]References[/blue]. Click the [blue]Browse[/blue] button then navigate your way too and select the [blue]external db file[/blue] (don't forget to select file type of mdb).[/li]
[li]The db should now appear in the References listing with a check mark.[/li]
[li]Click OK and your set.[/li][/ol]
Now to open any form in the external db:
Code:
[blue]   OpenExtFrm("[purple][b]ExternalFormName[/b][/purple]")[/blue]
[purple]Note: the code doesn't check if the form exist.[/purple]

Thats it . . . let me know how ya make out . . .



Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top