Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Using IF...Then when merging dates from Access to Word
I am trying to create a document that brings a date from Access to Word.
Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
#2
|
|||
|
|||
The comparison operators , and so on do not work with dates - to get
numbers that can be compared in a useful way, try { IF{MERGEFIELD Anniversary \@YYYYMMDD } 20042106 "{Mergefield Anniversary \@"MMMM d,yyyy"}" "June 21, 2004"} Also, please note that there should be spaces around the "", it's advisable to put quotes round both results (as shown) and all the {} need to be the special field codes you can insert using cttrl-F9 Peter Jamieson "Ecofreak" wrote in message ... I am trying to create a document that brings a date from Access to Word. Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
#3
|
|||
|
|||
It's also better to do the manipulation with a query in Access. After all,
it is a database and Word is a word processor. -- 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 "Ecofreak" wrote in message ... I am trying to create a document that brings a date from Access to Word. Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
#4
|
|||
|
|||
I tried creating an IIF expression in a query:
IIF([Anniversary] 06/21/2004, [Anniversary], "June 21, 2004") but all I get is an error message. I'm not at work right now, so I can't tell you precisely what it says. Something to the effect that it doesn't recognize it as an If statement. How does one go about creating an expression to do what I want? "Doug Robbins" wrote: It's also better to do the manipulation with a query in Access. After all, it is a database and Word is a word processor. -- 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 "Ecofreak" wrote in message ... I am trying to create a document that brings a date from Access to Word. Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
#5
|
|||
|
|||
The date needs to be enclosed inside ##
IIF([Anniversary] #06/21/2004#, [Anniversary], "June 21, 2004") -- 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 "Ecofreak" wrote in message ... I tried creating an IIF expression in a query: IIF([Anniversary] 06/21/2004, [Anniversary], "June 21, 2004") but all I get is an error message. I'm not at work right now, so I can't tell you precisely what it says. Something to the effect that it doesn't recognize it as an If statement. How does one go about creating an expression to do what I want? "Doug Robbins" wrote: It's also better to do the manipulation with a query in Access. After all, it is a database and Word is a word processor. -- 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 "Ecofreak" wrote in message ... I am trying to create a document that brings a date from Access to Word. Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
#6
|
|||
|
|||
You must use the correct syntax - see Peter's example. The field boundaries
are inserted with CTRL+F9 See also http://www.gmayor.com/formatting_word_fields.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Ecofreak wrote: I tried creating an IIF expression in a query: IIF([Anniversary] 06/21/2004, [Anniversary], "June 21, 2004") but all I get is an error message. I'm not at work right now, so I can't tell you precisely what it says. Something to the effect that it doesn't recognize it as an If statement. How does one go about creating an expression to do what I want? "Doug Robbins" wrote: It's also better to do the manipulation with a query in Access. After all, it is a database and Word is a word processor. -- 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 "Ecofreak" wrote in message ... I am trying to create a document that brings a date from Access to Word. Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
#7
|
|||
|
|||
Thanks to both Doug and Peter. I was able to create the statement I needed
in both Word and Access. This will definitely prove helpful in the future. "Ecofreak" wrote: I am trying to create a document that brings a date from Access to Word. Problem is, I want all dates prior to a set date to register as one date and all others to register as the date in the database. I created the following expression in Word {IF{MERGEFIELD Anniversary}6/21/2004 {Mergefield Anniversary\@"MMMM d,yyyy"} "June 21, 2004"}. But the only output I get, regardless of the Anniversary date is the Anniversary date. Is there a way to write this expression that will give me the answer I want? (Either in Word or in an Access Query?) BTW using Office 2000. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Duplicate Records Merging with Access | Mailmerge | |||
Merging Access into Word - characters changed | Mailmerge | |||
Word Document: merging a lot of info from Access | Mailmerge | |||
How do I get UK date format merging into word from Access? | Mailmerge | |||
merging from access | Mailmerge |