Reply
 
Thread Tools Display Modes
  #1   Report Post  
Ecofreak
 
Posts: n/a
Default 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   Report Post  
Peter Jamieson
 
Posts: n/a
Default

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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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   Report Post  
Ecofreak
 
Posts: n/a
Default

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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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   Report Post  
Graham Mayor
 
Posts: n/a
Default

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   Report Post  
Ecofreak
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate Records Merging with Access markmidwest Mailmerge 3 June 13th 05 07:10 PM
Merging Access into Word - characters changed LindaM Mailmerge 2 May 9th 05 03:58 PM
Word Document: merging a lot of info from Access pepenacho Mailmerge 1 March 22nd 05 09:01 PM
How do I get UK date format merging into word from Access? Gavvers Mailmerge 3 March 18th 05 12:24 PM
merging from access Ilan Mailmerge 3 December 30th 04 10:30 PM


All times are GMT +1. The time now is 11:48 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"