Need help in Mail Merge

L

leach613

I have a macro that I use to merge my word document with my timecard word
database. The only reason I have a macro to do the merge is to ask the
person what is the pay period so it can be replaced in each document.

This has been working great so far but now I need to separate the printing
of the timecards by department and shift. I've added these fields to my
database but need a way to query this my database each time I run my macro.

Can anyone tell me how to filter my database using word vba. I had a SELECT
statement but I kept getting an error so I'm not sure if I had the statement
written correctly.

Example of my code:

With ActiveDocument.MailMerge
.DataSource.QueryString = _
"SELECT * FROM H:\Accounting\Timecard.doc WHERE ((Dept = strDept)
AND (Shift = strShift))"
.Destination = wdSendToNewDocument
.Execute

End With

Any help would be appreciated.

Evy
 

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