Re: Mail Merge Module fails to open Data Source

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Just the start for you in DAO:

1. Create 2 Queries called:

qryContractData_Base
qryContractData_Custom

qryContractData_Base is the same with your original SQL without the WHERE
condition, i.e. is:

****
SELECT DISTINCTROW tblClientData.FileNumber, tblClientData.ClientFullName,
tblClientData.SpouseFullName, tblClientData.ClientRole
FROM tblClientData
****

The SQL String of the qryContractData_Custom is not important as we modify
it in code. You can simply copy the qryContractData_Base and rename the new
copy qryContractData_Custom

2. Before you start the MailMerge execution code, code something like

Dim db As DAO.Database
Dim qdf as DAO.QueryDef

Set db = DBEngine(0)(0)
Set qdf = db.QueryDefs("qryContractData_Custom")
qdf.SQL = db.QueryDefs("qryContractData_Base").SQL & _
" WHERE tblClientData.FileNumber = " & Me.FileNumber
qdf.Close

Set qdf = Nothing
Set db = Nothing
DoEvents

and then continue your MailMerge code but use the qryContractData_Custom as
the DataSource. Since this query is not parametrised (the Parameter has
been resolved to explicit value), Word MailMerge will be able to use it.

This way, you don't have to use temporary Table.

It is probably true that MailMerge can use the Table faster than the Query
but without method, you need to use a Make-Table Query to select Record(s)
to create the Table (which need hard-disk writes) then the code needs to
read from the hard-disk again. You then have to delete the Table (hard-disk
access again).

With the customised Query like above, the whole process only involve the
selection similar to the selection done by your Make-Table Query. Thus, the
customised Query should be much faster for the whole process.

--
HTH
Van T. Dinh
MVP (Access)




"Robert Blair via AccessMonster.com" <forum@xxxxxxxxxxxxxxxxx> wrote in
message news:4ec463bced964db181560489ea925531@xxxxxxxxxxxxxxxxxxxx
> I'm going to take your advice and explore the DAO method.


.



Relevant Pages

  • Re: Complex e-mail merge with unique attachment Repost
    ... running a catalog type mailmerge against the same data source as the memos ... name or the project given in the subject line of the e-mails. ... the info from the same query. ... Is there a way to sort the above list in numerical order so ...
    (microsoft.public.word.mailmerge.fields)
  • Re: RE Insert Access RTF fields with appropriate format - Peter Jamieson
    ... Using Mailmerge without code, you have to export the content of each field containing rtf text to a disk file, then use INCLUDETEXT to insert it. ... connect to that query using the DDE connection method ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Openrecordset Query with Parameter
    ... Fields - the fields collection ... In order to change them at run-time, I use DAO to retrieve the name of the fields in the query and assign it as the ControlSourceof the appropriate fields. ... If you are using a form to open the report, and the form contains a field with the parameter value in question, then it would be possible to have the "Z1" just reference the parameter value on the form, which I am assuming will be open when the report is run. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Syntax Error in field definition
    ... If at first you don''''''''t succeed, destroy all evidence that you tried. ... As a result, your query won't work in DAO code, nor through the normal ...
    (microsoft.public.access.modulesdaovba)
  • Re: Automate opening a merge with Mailmerge Recipients open
    ... To disconnect the data source, change the type of document from a mailmerge document to a normal Word document and then change it back to the desired type of mail merge main document. ... As far as the "field mapping" is concerned, if by that it can be implied that you are not using the actual names of the fields from the data source, then it would be far better if you did use the data source field names directly as then no mapping would be required. ... datasource linked to the query, only now the query has been changed. ...
    (microsoft.public.word.mailmerge.fields)