Retrieving an Access form from Word

G

Guest

Hi
I am trying to open an Access form from Word, using the following code

Sub OpenAccessFormFromWord(
'Open the source databas
Dim ac As Objec
Set ac = CreateObject("Access.Application"
Dim db As Databas
Set db = OpenDatabase("myDb"
ac.DoCmd.OpenForm "myForm
End Su

and receive error message smth like 'Form myForm cannot be opened at this time'. (As an aside, I am not sure if the Access.Application object is activated correctly..I do have DAO library checked). If someone could point me to a bit code successfully performing this task, I would be extremely grateful
Thank you.
 
S

solex

Demyan,

I have found that creating a public method in an Access module to show your
form (shown below as ShowMyForm") is a much better and stable approach. An
example of the code in Word or any other Office application is shown here:

Sub ShowAccessForm()
Dim objAccess As Object

On Error GoTo ErrorHandler

Set objAccess = GetObject(UNC_TO_YOUR_DATABASE_APP)
Call objAccess.Run("ShowMyForm", 1) '<--- Here is your public method
that shows a form

ExitHandler:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " " & Err.Description
Resume ExitHandler
End Sub


Also DAO does not include the DoCmd construct.

Regards,
Dan


demyan said:
Hi,
I am trying to open an Access form from Word, using the following code:

Sub OpenAccessFormFromWord()
'Open the source database
Dim ac As Object
Set ac = CreateObject("Access.Application")
Dim db As Database
Set db = OpenDatabase("myDb")
ac.DoCmd.OpenForm "myForm"
End Sub

and receive error message smth like 'Form myForm cannot be opened at this
time'. (As an aside, I am not sure if the Access.Application object is
activated correctly..I do have DAO library checked). If someone could point
me to a bit code successfully performing this task, I would be extremely
grateful.
 
G

Guest

Thank you

----- solex wrote: ----

Demyan

I have found that creating a public method in an Access module to show you
form (shown below as ShowMyForm") is a much better and stable approach. A
example of the code in Word or any other Office application is shown here

Sub ShowAccessForm(
Dim objAccess As Objec

On Error GoTo ErrorHandle

Set objAccess = GetObject(UNC_TO_YOUR_DATABASE_APP
Call objAccess.Run("ShowMyForm", 1) '<--- Here is your public metho
that shows a for

ExitHandler
Exit Su
ErrorHandler
MsgBox Err.Number & " " & Err.Descriptio
Resume ExitHandle
End Su


Also DAO does not include the DoCmd construct

Regards
Da


demyan said:
Hi
I am trying to open an Access form from Word, using the following code
'Open the source databas
Dim ac As Objec
Set ac = CreateObject("Access.Application"
Dim db As Databas
Set db = OpenDatabase("myDb"
ac.DoCmd.OpenForm "myForm
End Su
time'. (As an aside, I am not sure if the Access.Application object i
activated correctly..I do have DAO library checked). If someone could poin
me to a bit code successfully performing this task, I would be extremel
grateful
 

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