retrieve Access form from Word

D

demyan

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.
Thank you.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?ZGVteWFu?=,

Go to the Access VBA Help and look carefully at the second example for the Application
Object.
- you need to use OpenCurrentDatabase (because you're manipulating the UI, not the
data; you're not using DAO)
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.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the
newsgroup and not by e-mail :)
 

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