View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default HELP: Error! No document variable supplied

Generally speaking, you are better off setting document variable values
to " " rather than "", because "" deletes the variable object. If you
are using DOCVARIABLE fields to insert the values and you always want to
avoid inserting a single space you can - in theory - use

{ IF "{ DOCVARIABLE myvar }" " " "{ DOCVARIABLE myvar }" }

or if you prefer to reduce the number of quotes you can probably get
away with

{ IF { DOCVARIABLE myvar } " " { DOCVARIABLE myvar } }

There are oddities in Word's handling of docvariable fields, and they
are not apparent at first because when the document variable collection
is empty, a field like

{ DOCVARIABLE myvar }

will display nothing, whereas if the document variable myvar does not
exist, but there is at least one other document variable in the
collection, the same field will display

"Error! No document variable supplied."

(In fact I think it may even be slightly more complicated than that)

Peter Jamieson

http://tips.pjmsn.me.uk
Visit Londinium at http://www.ralphwatson.tv

On 22/10/2009 20:13, sam wrote:
Hi All,

I have created a button in access form that exports certain details from the
form to a word template. But when exporting textfields that has no values (on
access form) displays an error:
Error! No document variable supplied.

Here is my code to resolve this issue but it's not working.

With doc
.variables("Name").Value = Nz((Name.Value), "")
.variables("Address").Value = Nz(Address.Value, "")
.variables("City").Value = !Nz(Me.City.Value, "")

.Fields.Update
End With

Thanks in advance