Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
justagrunt justagrunt is offline
external usenet poster
 
Posts: 7
Default docvariable when empty gives error - how to stop error text in doc

Hi,
Using docvariables in a mail merge.
Using a record set to isolate the data from and access table.
Address1 = Nz(![Address1])
Address2 = Nz(![Address2])
Address3 = Nz(![Address3])
Address4 = Nz(![Address4])
Address5 = Nz(![Address5])
Address6 = Nz(![Address6])

then

Set docvar = WordDoc.Variables

docvar.Item("Address1").Value = Address1
docvar.Item("Address2").Value = Address2
docvar.Item("Address3").Value = Address3
docvar.Item("Address4").Value = Address4
docvar.Item("Address5").Value = Address5
docvar.Item("Address6").Value = Address6

problem lies if any of the fields has no information i get error - no
document variable supplied showing on the document.
Thought I'd cleared it with the Nz function.
How do I get a round the problem of a docvariable having the possibility of
no information as the feild in access has no information.
Say no information for address feilds 5 and 6.



--
Regards
Bill
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default docvariable when empty gives error - how to stop error text in doc

The Access built-in Nz() function provides for two arguements.

Use Address1 = Nz(![Address1], " ")

so that Address1 will contain just a space if the corresponding field is
empty.

--
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

"justagrunt" wrote in message
...
Hi,
Using docvariables in a mail merge.
Using a record set to isolate the data from and access table.
Address1 = Nz(![Address1])
Address2 = Nz(![Address2])
Address3 = Nz(![Address3])
Address4 = Nz(![Address4])
Address5 = Nz(![Address5])
Address6 = Nz(![Address6])

then

Set docvar = WordDoc.Variables

docvar.Item("Address1").Value = Address1
docvar.Item("Address2").Value = Address2
docvar.Item("Address3").Value = Address3
docvar.Item("Address4").Value = Address4
docvar.Item("Address5").Value = Address5
docvar.Item("Address6").Value = Address6

problem lies if any of the fields has no information i get error - no
document variable supplied showing on the document.
Thought I'd cleared it with the Nz function.
How do I get a round the problem of a docvariable having the possibility
of
no information as the feild in access has no information.
Say no information for address feilds 5 and 6.



--
Regards
Bill



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual basic runtime error 5216, there is a printer error pat@stlukeshospital Microsoft Word Help 2 June 6th 18 08:53 PM
Word 2003 - when closing receive 'Runtime Error 91' error messages RLC Web Microsoft Word Help 1 January 11th 06 06:16 AM
how do I stop a runtime error Joey Microsoft Word Help 1 January 4th 06 06:07 AM
Stop error message - "Compile Error in hidden module appearing" Howard18 Microsoft Word Help 1 October 20th 05 05:12 PM
I get "subscript out of range" error message. How do I stop this? adl1704 New Users 1 December 6th 04 04:00 AM


All times are GMT +1. The time now is 01:00 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"