Using Variables From Access

W

williamr

I'm trying to open word 2003 and drop in some information that I am storing
in Access. I put in the following code but it tells me it can't find
xDeveloperName. The bookmark is in the document and is named 'xname' I have
the local window open and see xDeveloperName. Can someone help me?? Thanks
in Advance

Dim objword As Word.Application
Set objword = CreateObject("Word.application")
With objword
.Visible = True
.Documents.Open ("M:\OffSiteInformation\3-LetterSamples\Test1.doc")
.ActiveDocument.Bookmarks("xName").Select
.Selection.Text = (CStr(Forms!frmOffsiteRelease!xDeveloperName))
End With
 
P

Peter Jamieson

What happens if you use VBA Immediate mode to do:

print (CStr(Forms!frmOffsiteRelease!xDeveloperName))

? Are you absolutely sure that either the form field or the underlying data
field is called xDeveloperName, or is that just a label that suggests that
that is what it's called.

Peter Jamieson
 
W

williamr

Hi. It's name is xdeveloperName. I'm using the the instructions from "How
to send the current record to Word 200 with automation. Article ID 210271.
I don't know that I'm doing this correctly, is there a better way to get a
variable from a filtered query to a word document>
 
P

Peter Jamieson

What happens if you use VBA Immediate mode to do:
?

I don't know that I'm doing this correctly, is there a better way to get a
variable from a filtered query to a word document>

There are two different things here:
a. how you get the data from Access
b. how you insert the data into Word

I'm much more familiar with the 2nd of those two, but when I tried your
approach it worked here. The problem seems to me to be with (a) rather than
(b) which is why I asked...

e.g. does that work? If not, do any other fields in the form work? etc.

Peter Jamieson
 
W

williamr

It says it can't find that variable, but this is what is in the local window:
: xDeveloperName : "Day Star Ventures, LLC" : Variant/String
 
P

Peter Jamieson

As I understand it, if xDeveloperName is a field in the form, you need to
use

Forms!frmOffsiteRelease!xDeveloperName

otherwise, if it's a VBA variable, which is what I would assume it is given
what you are seeing, you probably just need to use

CStr(xDeveloperName))

Peter Jamieson
 

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