Custom Mail Merge Query Option

L

LDanix

Is it possible to create a custom query using an "IF" statement? If so, how
would it be established?
 
P

Peter Jamieson

Not if you mean query in the sense that Word usually uses.

If you can say a little more about what you're trying to achieve, maybe we
can give you some pointers.
 
L

LDanix

I am working with dates. I want Word to merge only records are that are
listed with "today's date". I was thinking something like {IF MERGEFIELD date
"Today's Date"} Where "Today's Date" is equal to the same type of field that
can be added to any Word document to display the current date.

I know that I could do this by changing the Query options every day, but I
am just trying to avoid that step.
 
P

Peter Jamieson

Well, you could use something like

{ IF "{ MERGEFIELD mydate \@YYYYMMDD }" = "{ DATE \@YYYYMMDD }"
"put all your text etc. here" "" }

but unfortunately, that will still produce one blank letter/page/e-mail for
all the records that do not match.

Instead, you could put

{ SKIPIF "{ MERGEFIELD mydate \@YYYYMMDD }" <> "{ DATE \@YYYYMMDD }" }

at the beginning of your merge main document - just be aware that the Word
Help in Word 2000 and later advises you not to use SKIP.
 
L

LDanix

"\@YYYYMMDD" Does that specify the format of the date, or do I need to
replace YYYYMMDD with an actual date?
 
P

Peter Jamieson

It specifies a format. The syntax of these fields is described in Word Help.
You only need the format switch because the format of the date coming in
from a merge data source may not be the same as the format Word uses when it
generates a date from { DATE }. I only use YYYYMMDD through force of habit
(it's the format you need to use if you want to use > or < instead of = to
decide which date is earlier).
 

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