Invalid Operation with Mail Merge using Split Database

J

Joel'

I have a database that uses mailmerge to generate a transmittal form
and save it as a file. The functionality worked fine as a standalone
database. I had to split the database to accomdate three users and now
I get a "Invalid Operations" error when I try to run the merge part of
the program. Here is what I have behind the button.

Dim db As Database
Dim rst As DAO.Recordset
Dim appWord As Word.Application
Dim ActiveDocument As Object
Dim intCount As Integer
Dim strDocsPath As String
Dim strSaveDocsPath As String
Dim strSQL As String
Dim strTableName As String

Set db = CurrentDb()

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

DoCmd.SetWarnings False

Set rst = db.OpenRecordset("Mergeloans", dbOpenTable)
intCount = DCount("*", "Mergeloans")
If intCount > 0 Then
vLoanNum = rst.Fields("LoanNumber").Value
Call MakeF649
End If

Here is the public function:

Dim appWord As Word.Application
Dim objWord As Word.Document
Dim ActiveDocument As Object

Set appWord = CreateObject("Word.Application")
strDocsPath = "C:\Collect\"
strSaveDocsPath = "K:\Archived Collateral Files\"
Set objWord = GetObject(strDocsPath + "SBA649.doc")

With objWord
.Application.DisplayAlerts = wdAlertsNone
.Application.Visible = False
.MailMerge.Destination = wdSendToNewDocument
.MailMerge.Execute
.Application.Options.PrintBackground = False
.Application.ActiveDocument.PrintOut
.Application.Selection.WholeStory
.Application.Selection.Fields.Unlink
.Application.Selection.HomeKey
.Application.ActiveDocument.SaveAs strSaveDocsPath & vLoanNum & "
SBA649" & Format(Now(), " mmm dd, yyyy ") & ".doc"
.Application.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
End With

objWord.Close SaveChanges:=wdDoNotSaveChanges

appWord.Application.Quit


Can anyone see anything wrong?? The "K" drive is the local share. The
new back end is stored in "K:\software\ colateral file room_be.mdb" I
would really appreciate any help anyone could give me....
 
J

Joel'

It seems that I have found the answer. The use of "dbOpenTable" can
only be used on local tables. You must use "dbOpenDynaset" for those
databases that are split. Once I made the change, everything
functioned fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top