Template Question

J

Jeff

i am building a template in Word 2002. I have a few DocVariables that are
populates from fields in a database. After a new doc is created if the fields
in the recordset in empty the DocVariable shows Error! No document variable
supplied. No matter what i try i cant get this to ignore the fact that its
empty. So i guess my question is this. Either in VBA or with fieldcodes how
can i get rid of that error?
 
D

Doug Robbins - Word MVP

You can use an If...then...Else field construction as follows.

{ IF { DOCVARIABLE variablename } = "Error! No document variable supplied" "
" "{ DOCVARIABLE variablename }" }

But I usually test for data in the code and set the value of the variable to
" " if there is nothing.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Jeff

Thanks for the reply Doug. Here i a little Code...

..Variables("Variablename").value =rs.Fields(1)

if rs.Fields(1) ="" then ("Variablename'') = Error! No document variable

Even if i Assign the value "" Manually i still get the error. the only time
i dont have the error is when a string populates the Variable. Any ideas?
 
D

Doug Robbins - Word MVP

If rs.Fields(1) = "" then
.Variables("Variablename").Value = " " 'there is a space between the
quote marks.
Else
.Variables("VariableName").Value = rs.Fields(1)
End if

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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