Pedro Janssen
pedro at plex.nl
Wed Jan 28 13:40:51 CST 2004
Hello Marty, it took me a while, but i solved the problem. After changing the code many times. Also with help from the one you gave me. I still received the error. I found an article in the Microsoft Knowledge base where the code i used in A97 was converted by microsoft to A2K. I changed my code to this one, but then i received an error that the ODBC could't open the database. I made a new access driver with the new .mdw file. Decompiled the database and both errors were gone. Thanks for your time. Pedro ----- Original Message ----- From: "MartyConnelly" <martyconnelly at shaw.ca> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Thursday, January 22, 2004 12:00 AM Subject: Re: [AccessD] error after converting (mailmerge) > I can get this to work with Access97 to Word2003 (my default) by > dropping some extraneous code,ie. not using connection string. > The mdb I am opening is seperate from the one I am running Access in. > > It does however open 2 copies of word 1 default (document3.doc) and 1 > (form letters1.doc) > It also prints too. does not close either word document. > > Sub test() > Dim bltest As Boolean > bltest = True > CreateMergeDoc bltest, True > End Sub > Sub CreateMergeDoc(UseDDE As Boolean, PrintDoc As Boolean) > > Dim WordDoc As Word.Document > Dim strLetter As String > Dim strConnect As String > Dim WordApp As Word.Application > > Set WordApp = CreateObject("Word.Application") > > Set WordDoc = WordApp.Documents.Add > With WordDoc.MailMerge > > .OpenDataSource _ > Name:="C:\Documents and Settings\marty\My > Documents\WordMergetestold97.mdb", _ > ReadOnly:=True, LinkToSource:=True, _ > SQLStatement:="SELECT * FROM [Table1] WHERE Table1.MyField = " > & 123 & ";" > > ' With Fields > '............... > 'End With > > 'With WordApp.Selection > '............... > 'End With > > > With WordDoc.MailMerge > .DataSource.FirstRecord = 1 > Debug.Print .DataSource.TableName > .Destination = wdSendToNewDocument > > .Execute > > If PrintDoc Then > .Application.Options.PrintBackground = False > .Application.ActiveDocument.PrintOut > End If > End With > > WordApp.Visible = True > End With > End Sub > > pedro at plex.nl wrote: > > >Hello Group, > > > >i converted a A97 secured database to A2K. > >After making the changes in Wrkgadmin.exe and the ODBC Data Sources, i changed the names in the module. After running the mailmerge i get an error: Run-time error '5922' Word was unable to open the data source. The debug selects the .OpenDataSource from the code below. > > > >I figure out why this error occurs. > > > >TIA > > > >Pedro Janssen > > > > > > > > > >Sub CreateMergeDoc(UseDDE As Boolean, PrintDoc As Boolean) > > > > Dim WordDoc As Word.Document > > Dim strLetter As String > > Dim strConnect As String > > Dim WordApp As Word.Application > > > > Set WordApp = CreateObject("Word.Application") > > > > Set WordDoc = WordApp.Documents.Add > > With WordDoc.MailMerge > > If UseDDE Then > > strConnect = "QUERY Uitvoer" > > Else > > strConnect = "DSN=MS Access 2000 " _ > > & "Database;DBQ=E:\Cytologie\positieven\" _ > > & "BeveiligdPOSITIEVEN(A2K).mdb;" _ > > & "FIL=MS Access;" > > End If > > .OpenDataSource _ > > Name:="E:\Cytologie\positieven\BeveiligdPOSITIEVEN(A2K).mdb", _ > > ReadOnly:=True, LinkToSource:=True, _ > > Connection:=strConnect, _ > > SQLStatement:="SELECT * FROM [Uitvoer], [Aanvrager] WHERE Uitvoer.AanvragerID = Aanvrager.AanvragerID AND Uitvoer.ControleID = " & Forms![Brief]![veld] & ";" > > > > With Fields > > ............... > > End With > > > > With WordApp.Selection > > ............... > > End With > > > > > > With WordDoc.MailMerge > > .DataSource.FirstRecord = 1 > > > > .Destination = wdSendToNewDocument > > > > .Execute > > > > If PrintDoc Then > > .Application.Options.PrintBackground = False > > .Application.ActiveDocument.PrintOut > > End If > > End With > > > > WordApp.Visible = True > > End With > >End Sub > > > >_______________________________________________ > >AccessD mailing list > >AccessD at databaseadvisors.com > >http://databaseadvisors.com/mailman/listinfo/accessd > >Website: http://www.databaseadvisors.com > > > > > > > > -- > Marty Connelly > Victoria, B.C. > Canada > > > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > >