Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

Mail Merge Update

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AccessARS - 26 Oct 2005 00:45 GMT
I have a mail merge document that is linked to an Access database table.  A
VBA procedure runs from Access that updates that table thereafter opens the
linked mail merge document.  My problem is that when I open the mail merged
document through the Access VBA procedure it does not update the record
in the merged doc but when I open the same document manually, first it
prompts me that it will run a SQL statement from the Access table to merge
that data and when I click OK it shows the new record. (keep in mind that
when the same mail merge document is opened through the VBA procedure it does
not prompt me for
anything instead opens the document with the last existing record).

Is there a way that I can code the Word document to somehow refresh the
merged records on open since it does not do so when I open it through my
procedure?

Any assistance would be greatly appreciated.
Doug Robbins - Word MVP - 26 Oct 2005 05:17 GMT
I would help if you showed the procedure that you are running.  Copy and
paste the code into a message that you post back here.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I have a mail merge document that is linked to an Access database table.  A
> VBA procedure runs from Access that updates that table thereafter opens
[quoted text clipped - 15 lines]
>
> Any assistance would be greatly appreciated.
AccessARS - 26 Oct 2005 18:07 GMT
Here it is and thank you...

Private Sub cmd_Informal_Click()
Dim qrf As querydef
Dim Name As String
Dim db As Database
Dim rst As Recordset

If IsNull(Me!Name.Value) Then
   MsgBox "Please enter Full Name to continue.", vbExclamation, "MISSING
FULL NAME"
   Me!Name.SetFocus
   Exit Sub
End If

Name = Me!Name.Value

If Name = Null Then
   MsgBox "Please enter Agent name.", vbExclamation, "MISSING AGENT NAME"
   Exit Sub
End If

Set db = CurrentDb

DoCmd.SetWarnings False

   DoCmd.RunSQL "delete from temp_Informal"
   
   Set qrf = db.QueryDefs("qry_Informal")
       qrf.Parameters("name") = Name
       qrf.Execute
   Set qrf = Nothing
   
DoCmd.SetWarnings True

Set rst = db.OpenRecordset("temp_Informal")

With rst
   If .EOF = True Then
    MsgBox "There are no records available for:" & vbCrLf & Me!Name &
vbCrLf & "Please check the spelling of the name.", vbExclamation, "NAME DOES
NOT EXIST"
       Me!Name.SetFocus
       .Close
       Exit Sub
   Else
       DoCmd.SetWarnings False
   
       DoCmd.RunSQL "delete from temp_Occurrences"
       
       Set qrf = db.QueryDefs("qryComplete Occurrence History")
           qrf.Parameters("name") = Name
           qrf.Execute
       Set qrf = Nothing
   
       DoCmd.SetWarnings True
               
       
       Set rst = db.OpenRecordset("temp_Occurrences")
       
           If .EOF = True Then
               MsgBox "There are no occurrences to report for" & Name,
vbExclamation, "NO OCCURRENCES"
               Me!Name.SetFocus
               .Close
               Exit Sub
           Else
           Dim Idoc
           Set Idoc = CreateObject("Word.Application")
               Idoc.Visible = True
               Idoc.Documents.Open
Filename:="\\holnt01\public\Projects-Hollywood\S3\Databases\Working\Attendance\Informal Merge.doc"
               
               DoCmd.OutputTo acOutputReport, "Occurrence_History",
acFormatRTF,
"\\holnt01\public\Projects-Hollywood\S3\Databases\Working\Attendance\OccurrenceHistory.doc", True
               .Close
           
           End If
   End If
   
End With

End Sub

> I would help if you showed the procedure that you are running.  Copy and
> paste the code into a message that you post back here.
[quoted text clipped - 18 lines]
> >
> > Any assistance would be greatly appreciated.
 
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.