You could add the SQL Statement to the OpenDataSource method. The OpenDataSource method takes the following parameters:
Name, Format, ConfirmConversions, ReadOnly, LinkToSource, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Connection, SQLStatement, SQLStatement1, OpenExclusive, SubType
You'll see two
SQLStatement references -
SQLStatement &
SQLStatement1.
SQLStatement accepts query strings of up to 255 characters. If the query string is longer than 255 characters,
SQLStatement specifies the first portion of the string, and
SQLStatement1 specifies the second portion.
You can export the current parameters to a new document, using code like:
Code:
Sub Test()
Dim StrMMData As String, DocTmp As Document
With ActiveDocument.MailMerge
If .MainDocumentType <> wdNotAMergeDocument Then
StrMMData = StrMMData & "Mail Merge Data Source Name:" & vbCr & .DataSource.Name & vbCr
StrMMData = StrMMData & "Mail Merge Connect String:" & vbCr & .DataSource.ConnectString
StrMMData = StrMMData & vbCr & "Mail Merge Query String:" & vbCr & .DataSource.QueryString
Set DocTmp = Documents.Add
DocTmp.Range.Text = StrMMData
Else
MsgBox "Not A Merge Document"
End If
End With
End Sub
As for the necessity to use DDE, I suggest you verify that on a specialist Access forum (e.g.
http://www.accessforums.net/)