Merging to Word - How & Where do I place criteria?

  • Thread starter Thread starter MAC
  • Start date Start date
M

MAC

I am trying to merge fields from all records in an Access database to Word
document (with the merge fields already in it). It works well, but I need
to tell Access to do the merge ALL that meet two condtions: 1) if a field
named "done" is UNchecked and 2) if the field "Letter1" is CHECKED (the same
will continue for Letter2, Letter3 & Letter 4). How & where do I place
these conditions? The event I placed in a button is:

Private Sub Command1_Click()
Dim App As Word.Application
Dim Doc As Word.Document

Set App = New Word.Application
Set Doc = App.Documents.Open("C:\NAME OF FOLDER\Letter1.doc")

App.Visible = True
App.WindowState = wdWindowStateMaximize

With Doc.MailMerge
.Execute (done = False)
Doc.Close False
End With

End Sub

Thank YOU!
 
It works well, but I need
to tell Access to do the merge ALL that meet two condtions: 1) if a field
named "done" is UNchecked and 2) if the field "Letter1" is CHECKED (the same
will continue for Letter2, Letter3 & Letter 4). How & where do I place
these conditions?

In a Query, on the criteria lines (four separate lines for your four
non-normalized Letter fields, which should probably be reconsidered!)

Export from the Query to the Word document - not from the table.
 
Thanks, John. But that has already been done. That's how I created the
Word doc with the merge fields. Now I have a form with a button. In the
button, an event & I need to know is how and where I place a condition for
the merge procedure.

Thanks for any help.
 
Thanks, John. But that has already been done. That's how I created the
Word doc with the merge fields. Now I have a form with a button. In the
button, an event & I need to know is how and where I place a condition for
the merge procedure.

I'm confused.

If the button launches Word, and if Word has a mailmerge using a
stored query in Access as its data source, then any criteria specified
on that query will be applied when the merge occurs. No code is needed
in the command which opens Word - the criteria are already THERE.

You say "it has already been done" - could you post the SQL of the
query? THAT - rather than in the code which opens Word - is the
appropriate place to set the criteria.
 
Back
Top