Open a specific form from external database

gstylianou

Registered User.
Local time
Tomorrow, 01:12
Joined
Dec 16, 2013
Messages
359
Hello my friends,

I would like to know whether it is possible somehow to open a particular form from external database into one other like a subform. Is that possible?

Has anyone dealt with something simillar ?

Regards,

George
 
whether it is possible somehow to open a particular form from external database into one other like a subform
into a subform, no not possible

You can open a form in another db by using vba code to create another instance of access and open the form in that instance. Something like this

Code:
     Dim Acc As Object
    
     Set Acc = CreateObject("Access.Application")
    Acc.OpenCurrentDatabase (path to other db)
    Acc.DoCmd.OpenForm name of form to be opened
 
into a subform, no not possible

You can open a form in another db by using vba code to create another instance of access and open the form in that instance. Something like this

Code:
     Dim Acc As Object
    
     Set Acc = CreateObject("Access.Application")
    Acc.OpenCurrentDatabase (path to other db)
    Acc.DoCmd.OpenForm name of form to be opened

Thanks again CJ_LOndon....i will try
 
Also, if you drag a form on to your desktop, a direct clickable link to that form is created on your desktop...

Sent from my SM-G925F using Tapatalk
 
Also, you can set a reference to another database, and open forms from that project, if that project exposes adequate code. So if you have a referenced library database DB1 that contains a form Form1, and exposes a method like...
Code:
Public Sub OpenForm1()
   DoCmd.OpenForm "Form1"
End Sub
...then from your current project you can run the library method ...
Code:
   DB1.OpenForm1
...and the form is opened and added to the Forms collection in your current project.
 
Also, you can set a reference to another database, and open forms from that project, if that project exposes adequate code. So if you have a referenced library database DB1 that contains a form Form1, and exposes a method like...
Code:
Public Sub OpenForm1()
   DoCmd.OpenForm "Form1"
End Sub
...then from your current project you can run the library method ...
Code:
   DB1.OpenForm1
...and the form is opened and added to the Forms collection in your current project.

Hi Markk,

You said: So if you have a referenced library database DB1 that contains a form Form1, and exposes a method like.....then from your current project you can run the library method ......and the form is opened and added to the Forms collection in your current project.

But: Which reference i must look for?

Thanks for your help
 
Hi Markk,

You said: So if you have a referenced library database DB1 that contains a form Form1, and exposes a method like.....then from your current project you can run the library method ......and the form is opened and added to the Forms collection in your current project.

But: Which reference i must look for?

Thanks for your help
 
what Markk is talking about is adding your other db as a library to your existing db.

in vba, go to tools>references>browse. Then browse to your other db and then add it.

Note you need to ensure you have no conflicts with module/sub/function names as well as any global variables, forms and reports.

But you will still not be able to add it as a subform to an existing form in your current db.

Using db's as library references is usually to enable routines which are common across a number of db's - might be import/export routines or something like email/sms generation.

Note: The Forms collection is a collection of all open forms, it is not the AllForms collection which is referenced by the subform sourceobject property.

The only way you can get the form in another db as a subform in the current db is to copy it across, then for the data sources, either use linked tables to the other db or modify the record/rowsource to reference the other db directly e.g.

SELECT *
FROM myTable IN 'PathToOtherdb'

Further note: if you want your library db to reference the current db (i.e. the db using the library) you use CodeDB rather than CurrentDB (CurrentDB in a library references the library)
 

Users who are viewing this thread

Back
Top Bottom