View Single Post
 
Old 12-22-2015, 08:02 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,385
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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/)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote