How to open form of a referenced mdb?

P

phpons

Hi,

In my Access application, I just referenced another mdb file that
contains an email application I want to use.
In my application, I now see the forms and code of the email
application.
The email application has a form frmCourriel
But if I write Docmd.open acForm "frmCourriel", I just an error.
It works if I select the other mdb in the VBIDE.

How can open the form in VBA? I gues I have to refernce the mdb, but
How?

TIA,

Philippe
 
V

Vantastic

Not sure of any other way other than importing the form and all of it's code
into your current application.

Cheerio
 
M

Marshall Barton

In my Access application, I just referenced another mdb file that
contains an email application I want to use.
In my application, I now see the forms and code of the email
application.
The email application has a form frmCourriel
But if I write Docmd.open acForm "frmCourriel", I just an error.


Create your own public procedure in the library mdb to open
the form. E.g.

Public Sub OpenLibraryForm(fromname as String)
DoCmd.OpenForm fromname
End Sub

You will probably want to make that more versatile by adding
optional arguments for the other things that OpenForm allows
you to specify.
 
P

phpons

Create your own public procedure in the library mdb to open
the form. E.g.

Public Sub OpenLibraryForm(fromname as String)
DoCmd.OpenForm fromname
End Sub

You will probably want to make that more versatile by adding
optional arguments for the other things that OpenForm allows
you to specify.

Thank's to both of you!
Marsh, I did what you suggested: perfect!
 
P

phpons

Thank's to both of you!
Marsh, I did what you suggested: perfect!

Marsh, a extra question if you mind!

I wrote the following snippet:
Public Function ppSendEmail()
' init de la gestion d'erreur: la bibliothèque peut ne pas avoir
été référencée
On Error GoTo ppSendEmail_Error

AccXP_Mail.modDivers.openFrmCourriel
' AccXP_Mail: the projects's name coming from AccXP_Mail.mdb, the
attached mdb
' modDivers: the nane of the code module
On Error GoTo 0
Exit Function

ppSendEmail_Error:
Debug.Print Err.Description
MsgBox ("La fonction d'envoi d'email n'est pas installée!")
' MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure ppSendEmail of Module basCommandBar"
End Function
 
P

phpons

Thank's to both of you!
Marsh, I did what you suggested: perfect!

sorry for the previous post sent by error!

So, I wrote the following:

Public Function ppSendEmail()
' init de la gestion d'erreur: la bibliothèque peut ne pas avoir
été référencée
On Error GoTo ppSendEmail_Error

AccXP_Mail.modDivers.openFrmCourriel
' AccXP_Mail: the name of the project of the AccXP_Mail.mdb
attached
' modDivers: the name of the code module
' openFrmCourriel: the public function that opne the form
On Error GoTo 0
Exit Function

ppSendEmail_Error:

MsgBox ("La fonction d'envoi d'email n'est pas installée!")
End Function

The problem is that in case the AccXP_Mail.mdb is not attached, a
compilation error is triggered due to the fact that
AccXP_Mail has not been declared. And the error is not trapped by the
On Error GoTo ppSendEmail_Error.
I tried different things to try declare AccXP_Mail, but unsuccessfully
till now.
How would you do that?

TIA,

Philippe
 
M

Marshall Barton

So, I wrote the following:

Public Function ppSendEmail()
' init de la gestion d'erreur: la bibliothèque peut ne pas avoir
été référencée
On Error GoTo ppSendEmail_Error

AccXP_Mail.modDivers.openFrmCourriel
' AccXP_Mail: the name of the project of the AccXP_Mail.mdb
attached
' modDivers: the name of the code module
' openFrmCourriel: the public function that opne the form
On Error GoTo 0
Exit Function

ppSendEmail_Error:

MsgBox ("La fonction d'envoi d'email n'est pas installée!")
End Function

The problem is that in case the AccXP_Mail.mdb is not attached, a
compilation error is triggered due to the fact that
AccXP_Mail has not been declared. And the error is not trapped by the
On Error GoTo ppSendEmail_Error.
I tried different things to try declare AccXP_Mail, but unsuccessfully
till now.

Sorry, but I don't understand what your question. If the
library mdb is not there, then you have a broken Reference
and your entire application will fail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top