473,378 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

MailMerge created by Access XP - Data Missing

I have a function in a Microsoft Access module (below) which creates a Word
XP Mailmerge document, drawing the data from Access XP. I can get the
connection to work fine. However, when I create the form letters, the data
from certain merge fields is missing. When I view the data in the MailMerge
Recipients dialog box, the data is not there either - the columns are there,
but the records have blanks where the data in those columns should be.

When I look at the Access source table, the data is fine.

I've tried Refreshing via MailMerge Recipients, with no luck. I've also
tried converting the document back to a Normal Document, then re-connecting
to the Access data source - also with no luck. I've even tried re-booting
the computer!

One thing that I think might be relevant: the three fields which aren't
showing data were added to the Access table after I initially set up the
Word connection manually (in order to add the Merge fields). So my
assumption is that something isn't refreshing.

Is this data being cached somewhere? Or am I just nuts?

Someone please rescue my sanity ...

Shannon

Public Function WordXP_letter(doc_name As String, sqlstmt As String,
AutoMerge As Boolean, Optional strQuery As String)
'On Error GoTo err_word_letter

Dim mywrd As Word.Application
Dim mydoc As Word.Document

'Stop
Set mywrd = New Word.Application

Set mydoc = mywrd.Documents.Add(doc_name)
mywrd.Visible = True
With mydoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource NAME:=CurrentDb.NAME, SQLStatement:=sqlstmt,
subtype:=wdMergeSubTypeWord2000
.Destination = wdSendToNewDocument
End With
If AutoMerge = True Then
mydoc.MailMerge.Execute True
mydoc.Close wdDoNotSaveChanges
End If
mywrd.Activate

'mywrd.Documents("Document1").Close wdDoNotSaveChanges
Set mydoc = Nothing
Set mywrd = Nothing
Exit Function

err_WordXP_letter:
Select Case Err.Number
Case Is = 5151
MsgBox ("Cannot find the template '" & doc_name & "'. Please
re-add it to the 'Secretary' folder and try again.")
Case Is = 4198
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Exit Function
End Select

End Function
Nov 13 '05 #1
2 1905
"Shannon Rotz" <sr***@shaw.ca> wrote in message news:<jVmcd.759809$gE.624153@pd7tw3no>...
I have a function in a Microsoft Access module (below) which creates a Word
XP Mailmerge document, drawing the data from Access XP. I can get the
connection to work fine. However, when I create the form letters, the data
from certain merge fields is missing. When I view the data in the MailMerge
Recipients dialog box, the data is not there either - the columns are there,
but the records have blanks where the data in those columns should be.

When I look at the Access source table, the data is fine.

I've tried Refreshing via MailMerge Recipients, with no luck. I've also
tried converting the document back to a Normal Document, then re-connecting
to the Access data source - also with no luck. I've even tried re-booting
the computer!

One thing that I think might be relevant: the three fields which aren't
showing data were added to the Access table after I initially set up the
Word connection manually (in order to add the Merge fields). So my
assumption is that something isn't refreshing.

Is this data being cached somewhere? Or am I just nuts?

Someone please rescue my sanity ...


Sounds like something's wrong with the Word doc. I'd drop in the new
fields and be sure to save it, close and retry the merge. If that
fails, I'd copy/paste the boilerplate to a new doc, and do the setup
again. Annoying, probably, but also likely quicker than sorting out
whatever's causing the problem. I'd be willing to bet it's the fact
that the datasource hasn't been reset, so Word isn't "seeing" the new
fields.
Nov 13 '05 #2
Also try doing a Compact on the database after making design changes,
and check the data in those columns - you sometimes get an 'error'
value in the whole column (which turns up blank) if there is a problem
with the data in one or more rows.

(david)

"Shannon Rotz" <sr***@shaw.ca> wrote in message
news:jVmcd.759809$gE.624153@pd7tw3no...
I have a function in a Microsoft Access module (below) which creates a Word XP Mailmerge document, drawing the data from Access XP. I can get the
connection to work fine. However, when I create the form letters, the data from certain merge fields is missing. When I view the data in the MailMerge Recipients dialog box, the data is not there either - the columns are there, but the records have blanks where the data in those columns should be.

When I look at the Access source table, the data is fine.

I've tried Refreshing via MailMerge Recipients, with no luck. I've also
tried converting the document back to a Normal Document, then re-connecting to the Access data source - also with no luck. I've even tried re-booting
the computer!

One thing that I think might be relevant: the three fields which aren't
showing data were added to the Access table after I initially set up the
Word connection manually (in order to add the Merge fields). So my
assumption is that something isn't refreshing.

Is this data being cached somewhere? Or am I just nuts?

Someone please rescue my sanity ...

Shannon

Public Function WordXP_letter(doc_name As String, sqlstmt As String,
AutoMerge As Boolean, Optional strQuery As String)
'On Error GoTo err_word_letter

Dim mywrd As Word.Application
Dim mydoc As Word.Document

'Stop
Set mywrd = New Word.Application

Set mydoc = mywrd.Documents.Add(doc_name)
mywrd.Visible = True
With mydoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource NAME:=CurrentDb.NAME, SQLStatement:=sqlstmt,
subtype:=wdMergeSubTypeWord2000
.Destination = wdSendToNewDocument
End With
If AutoMerge = True Then
mydoc.MailMerge.Execute True
mydoc.Close wdDoNotSaveChanges
End If
mywrd.Activate

'mywrd.Documents("Document1").Close wdDoNotSaveChanges
Set mydoc = Nothing
Set mywrd = Nothing
Exit Function

err_WordXP_letter:
Select Case Err.Number
Case Is = 5151
MsgBox ("Cannot find the template '" & doc_name & "'. Please
re-add it to the 'Secretary' folder and try again.")
Case Is = 4198
Resume Next
Case Else
MsgBox Err.Number & " - " & Err.Description
Exit Function
End Select

End Function

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dixie | last post by:
I have an application which does a lot of reports (letters) by automation with Word. The mail merge main document is a Word template and I transfer a text file out to a prenamed filename to act as...
0
by: Bud Zielinski | last post by:
Some of our users have converted to Office 2003. Our Access app is in 2000. they run it in Access 2003 with Access 2000 as the default file format. When doing a merge from the partial code...
1
by: Bud Zielinski | last post by:
Some of our users have converted to Office 2003. Our Access app is in 2000. they run it in Access 2003 with Access 2000 as the default file format. When doing a merge from the partial code...
1
by: Nicolae Fieraru | last post by:
Hi All, I made an access Application which uses mailmerge function. I have a query which I use to mailmerge to a word document. I created the word document as a new document and I saved onto the...
4
by: Ray Todd Jr | last post by:
I can't get ths code to correctly execute. After I have clicked on a Access Form, I want the code to open the word document, merge the data, print the forms and then close the two windows that...
5
by: Dixie | last post by:
I have a mailmerge that works fine from an MDB database using the OpenDataSource method to send its data from a query within Access as part of an automation sequence. Now, if I compile that mdb...
10
by: John | last post by:
Hi I am trying to do a word mailmerge form within my vb.net app. My problem is how to do a query on one of my tables and use the result as the mail merge datasource. Any help would be...
9
by: Chubbly Geezer | last post by:
Hope you can help. I have created a mail merge word doc which seems to work fine. When I close and reload it asks if I wish to pull in the data. Great. However, I want to print the results of...
0
by: mleerog | last post by:
Hope someone can shed some light on a tricky error. I am trying to automate a mailmerge in VB.NET using Word 2003. The main document is a previously existing Word file. The data source is a text...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.