Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
AJ AJ is offline
external usenet poster
 
Posts: 36
Default Merge not wking from coding but does from Word doc

I have a mail merge doc using an access table as the datasource. In the tbl
for the datasource there are some yes/no fields. In my merge doc, I have some
if then else set up for these. When I am in the doc and click the merge all
works fine. But when I run the code in the database my if then else don't
work. It is the same info in the table both times. This is example of my if
then else in merge doc:
{IF{MERGEFIELD LegalAgeVio} = 0 "____""__X__"}
Basically if the field is no it will put a blank line, else it will mark the
line with an X.
When I merge from doc, these all are correct, but from the database, it
marks all of the with an X whether the statement is true or false. I have
copied my coding below. Any help would greatly be appreciated. I am at a
loss. I have done many of these and this is the first time this has been an
issue:

Private Sub cmdWarningLetter_Click()
Dim objWord As Word.Document

DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * From tblWarningLetter"
DoCmd.OpenQuery "qryWarningLetter"

Set objWord = GetObject("G:\Users\AmyC\child
labor\WordDocuments\WarningLetter.doc", "Word.Document")

objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource Name:="G:\Users\AmyC\child
labor\ChildLabor.mdb", LinkToSource:=True, Connection:="DSN=MS Access
Database;DBQ=G:\Users\AmyC\child labor\ChildLabor.mdb;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5" ' SQLStatement:="SELECT *
From[tblWarningLetter]"
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.ActiveWindow.WindowState = wdWindowStateMaximize
objWord.Close (wdDoNotSaveChanges)
Set objWord = Nothing

DoCmd.SetWarnings True

End Sub
 
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
Damsel In Distress - Command Button Coding HTML Word 2007 SP Microsoft Word Help 3 March 31st 08 08:51 PM
OfficeXSL Word and Excel document generation method - no coding Andrzej Dmoch Tables 0 October 5th 07 09:10 PM
Naming word tables or coding reference library with vba hornbecky83 Tables 6 January 21st 07 01:11 AM
Merging Multiple Docs in Word using color-coding [email protected] Microsoft Word Help 1 August 4th 06 05:03 PM
Complicated mail merge with html coding [email protected] New Users 1 April 24th 05 11:55 AM


All times are GMT +1. The time now is 12:59 AM.

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

About Us

"It's about Microsoft Word"