Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / November 2004

Tip: Looking for answers? Try searching our database.

WORD Merge Again

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil - 04 Nov 2004 02:26 GMT
Hi,
I have a form where the user enters a name of a word merge file, begin data,
end date and event type.  I have a command button which then process the
following code in the on click event (ingore the line wrap).

  Set objWord = GetObject("c:\Mailing List\" & Forms![Report
Menu]![MergeFile] & ".doc", "Word.Document")
 
  ' Make Word visible.
  objWord.Application.Visible = True
  ' Set the mail merge data source as Mailing List.

  objWord.MailMerge.OpenDataSource _
     Name:="c:\Mailing List\Mailing list.mdb", _
     LinkToSource:=True, _
     Connection:="QUERY MailMergeEvent", _
     SQLStatement:="SELECT Last_Name, First_Name, Organization, Address_1,
City, State, Zip FROM [MailMergeEvent]"
 
The SQL for the query MailMergeEvent is as follows:

SELECT DISTINCTROW [Mailing List].Last_Name, [Mailing List].First_Name,
[Mailing List].Mailing_List_Key, Last([Mailing List].Organization) AS
LastOfOrganization, Last([Mailing List].Address_1) AS LastOfAddress_1,
Last([Mailing List].City) AS LastOfCity, Last([Mailing List].State) AS
LastOfState, Last([Mailing List].Zip) AS LastOfZip
FROM [Mailing List] INNER JOIN [Transaction] ON [Mailing
List].Mailing_List_Key = Transaction.Mailing_List_Key
WHERE (((Transaction.Date) Between [Forms]![Report Menu]![Event_Start_Date]
And [Forms]![Report Menu]![Event_End_Date]) AND
((Transaction.Event)=[Forms]![Report Menu]![Event_Type_Combo]))
GROUP BY [Mailing List].Last_Name, [Mailing List].First_Name, [Mailing
List].Mailing_List_Key;

The merge worked before I added the "GROUP BY" line.  I now get a run-time
error 5922  on the objWord.MailMerge.OpenDataSource _........ code

What is a 5922 error or what is wrong with my group by code?  If I open the
query by itself it works fine.

Thanks,
Signature

Phil

Phil - 04 Nov 2004 06:37 GMT
Thanks for read my question, but I solved the problem.
FYI: When I replaced the field names in the SQLStatement:=" statement with
an * the merge worked fine.

Thanks,

> Hi,
> I have a form where the user enters a name of a word merge file, begin data,
[quoted text clipped - 37 lines]
>
> Thanks,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.