View Single Post
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
YisMan
 
Posts: n/a
Default merge word with access

hi everyone, this is my code which is the event handler for a button on a ms
access 2003 form:

Private Sub btMerge_Click()
Application.FollowHyperlink DLookup("receiptaddress", "settings")
Dim apWord As Word.Application
Set apWord = GetObject(, "word.application")
Dim docMerge As MailMerge
Set docMerge = apWord.ActiveDocument.MailMerge
With docMerge
If .MainDocumentType = wdNotAMergeDocument Then
.MainDocumentType = wdFormLetters
.OpenDataSource CurrentProject.FullName, , , , , , , , , , , "query
qrreceipts"
End If
.DataSource.QueryString = "select * from qrreceipts where [ReceiptID]="
& [ReceiptID]
End With
End Sub

the code runs fine and the document opens ok, then i get the security
message about the sql statement,so far so good.
then something funny happens, word opens the automating access database
*ANEW*! why, o why? its open there on the screen, it just makes everything so
foncusing.
moreover, more often then not an error is generated stating something about
a "Admin" useraccount not allowing it to open the db exclusively. but it is
OPEN!
can anyone help me simplify this mess?
--
Thankfully, YisMan