modules and microsoft mailmerge.

G

Guest

Hello. I have narrowed my problem down to my modules that are used in
queries in my database. my problem is that when I perform a mailmerge to a
word document the modules used seem to freeze-up the mailmerge. the modules
are used to summarize multiple records fields into a single field.
Below you will find an example of my code. It lists a patients X-rays
according to the date of visit. can anyone tell why this would give me
trouble when it is used in a query that is used in a mailmerge? and are
there any solutions?

Public Function ListXRay(TheSSN As String, TheDateofVisit As String) As
String
Dim rst As DAO.Recordset
Dim XRList As String
Set rst = CurrentDb.OpenRecordset("SELECT SSN, Radiograph,
DateOfVisit FROM [Imaging Studies] WHERE SSN='" & TheSSN & "' And
DateOfVisit=#" & TheDateofVisit & "#")
With rst
Do Until .EOF
XRList = XRList & ![Radiograph] & "; "
.MoveNext
Loop
End With
If Len(XRList) Then
XRList = Left(XRList, Len(XRList) - 2)
End If
ListXRay = XRList
End Function
 
G

Graham Mandeno

Hi Mike

When you connect to a mail merge data source, later versions of Word use an
ODBC connection. This has the advantage of accessing the data directly
without opening an instance of Access, but a disadvantage is that your query
cannot cann user-defined functions.

There may be a way to tell Word to use an old-style DDE connection, but if
so I don't know how to do it. Perhaps you could ask in one of the Word
newsgroups.

The way I always do a mailmerge is to create a delimited text file
containing all the records and fields I want to merge and then use that as
the data source. That way you avoid all sorts of problems with Access
permissions, ODBC limitations, etc.
 

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