bookmarks

J

Joanne

I am trying to drop info from my access table into a word document
'bookmark'. When I run the following code I get an error
- Runtime error 424 Object required.
Any ideas what I should be doing that I am not? I wonder if it has
something to do with the owordapp being properly activated.

Public Sub cboDirDeposit_AfterUpdate()
Dim oWordapp As Word.Application
Set oWordapp = New Word.Application

oWordapp.Documents.Open
("c:\NMWorkpackage\DirectDepAuthorization.Doc")
With oWordapp.ActiveDocument.Bookmarks
.Item("SSN").Range.Text = tblEmpContInfo.SSN
End With
End Sub

The bookmark in word is named SSN, and the field in the table is also
named SSN

Thanks for your time and help
 
M

MacDermott

I don't see anything in your code to tell Access which record of your table
to read.
 
V

Van T. Dinh

The Table "tblEmpContInfo" may have numerous Records, each having a
different SSN. Which SSN do you want to use?

Also, you cannot refer to an item of data in the Table as coded. Check
Access Help on the DLookUp function instead.
 
J

Joanne

In this particular application, there is only one record in the table
ever - it is used to produce the documents, and then is dumped until
the app is needed to do another document package.

In about 65 documents, there is a total of only 17 fields, used to
fill in blanks in the docs, many of them being reused many times, and
many docs having no bookmarks at all.

In my head it seems that I should be able to open a doc, look at the
activedocument.bookmarks collection, compare any bookmarks present in
the activedocument to the fields in my access table, and set the
bookmark in the document when there is a match.

I'm by no means even an intermediate access programmer so I am still
stumbling around trying to figure out how to do this.

I need to access that record in the table and have it opened up so
that I can grab the field values and plop them in the document - this
much I realize now from your's and MacDermott's comments.

I certainly will spend the afternoon learning about the dLookUp
function and how it might help me with this project. Any thoughs or
ideas you might have to lead me in the right direction (or maybe I am
thinking this all wrong and need to be pointed elsewhere) are very
welcome.

Thanks for your comments and consideration of my efforts
 
J

Joanne

A quick thought
Would I be able to use my code if I looked at 'frmContactInfo' instead
of directly at the table 'tblCOntactInfo'. I expect that if I am going
to look at the form for the data, I would need the form to be opened
and then use the current record info. Can I do this by referencing the
control on the form that has the data loaded in it?

Thanks again for your time
 
V

Van T. Dinh

Yes, you can use the reference to the Control on the Form to get the value
in the Control. Of course you need the Form to be open at the time and the
Control has meaningful value.

You may need to wrap the refernce to the Control with the Nz() function in
case the Control has Null value.
 

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