A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IF statement not working



 
 
Thread Tools Display Modes
  #1  
Old April 12th, 2010, 06:04 PM posted to microsoft.public.word.docmanagement
CPelkey
external usenet poster
 
Posts: 4
Default IF statement not working

I have a form where the user enters the number of reports for the current
year as well as the number of reports for the previous year. I want to use
this information to automatically tell the user whether the number of reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?
  #2  
Old April 12th, 2010, 07:22 PM posted to microsoft.public.word.docmanagement
Stefan Blom[_3_]
external usenet poster
 
Posts: 4,556
Default IF statement not working

Assuming that REPTotal and PrevYearREP are global variables or bookmarks,
they must be inserted as REF fields in your code:

{ IF { REPTotal } { PrevYearREP } "an increase" "a decrease" }

Also, note that each pair of field delimiters, { }, must be added by
pressing Ctrl+F9.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
I have a form where the user enters the number of reports for the current
year as well as the number of reports for the previous year. I want to use
this information to automatically tell the user whether the number of
reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The
field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?



  #3  
Old April 12th, 2010, 08:08 PM posted to microsoft.public.word.docmanagement
CPelkey
external usenet poster
 
Posts: 4
Default IF statement not working

Stefan, thanks for your reply!

I tried inserting the references using Ctrl+F9, but now instead of giving a
result, it comes back with the contents of the first reference. So whatever
number is in REPTotal displays in the field instead of either of the text
values =(

Is there anything else you can think of?

"Stefan Blom" wrote:

Assuming that REPTotal and PrevYearREP are global variables or bookmarks,
they must be inserted as REF fields in your code:

{ IF { REPTotal } { PrevYearREP } "an increase" "a decrease" }

Also, note that each pair of field delimiters, { }, must be added by
pressing Ctrl+F9.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
I have a form where the user enters the number of reports for the current
year as well as the number of reports for the previous year. I want to use
this information to automatically tell the user whether the number of
reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The
field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?



.

  #4  
Old April 12th, 2010, 08:22 PM posted to microsoft.public.word.docmanagement
Stefan Blom[_3_]
external usenet poster
 
Posts: 4,556
Default IF statement not working

How did you create the starting and closing braces? These must also be
inserted via Ctrl+F9 (or via the Field dialog box of course); otherwise you
haven't got a working IF field construct.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
Stefan, thanks for your reply!

I tried inserting the references using Ctrl+F9, but now instead of giving
a
result, it comes back with the contents of the first reference. So
whatever
number is in REPTotal displays in the field instead of either of the text
values =(

Is there anything else you can think of?

"Stefan Blom" wrote:

Assuming that REPTotal and PrevYearREP are global variables or bookmarks,
they must be inserted as REF fields in your code:

{ IF { REPTotal } { PrevYearREP } "an increase" "a decrease" }

Also, note that each pair of field delimiters, { }, must be added by
pressing Ctrl+F9.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
I have a form where the user enters the number of reports for the
current
year as well as the number of reports for the previous year. I want to
use
this information to automatically tell the user whether the number of
reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The
field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?



.




  #5  
Old April 12th, 2010, 09:42 PM posted to microsoft.public.word.docmanagement
CPelkey
external usenet poster
 
Posts: 4
Default IF statement not working

Yes, I am using Ctrl+F9 to enter all fields. I have several fields in the
document that all work perfectly well, but none of the If-Then-Else
statements I use seem to work. There must be some kind of syntax error I am
making, I just don't have the experience to be able to find it.


"Stefan Blom" wrote:

How did you create the starting and closing braces? These must also be
inserted via Ctrl+F9 (or via the Field dialog box of course); otherwise you
haven't got a working IF field construct.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
Stefan, thanks for your reply!

I tried inserting the references using Ctrl+F9, but now instead of giving
a
result, it comes back with the contents of the first reference. So
whatever
number is in REPTotal displays in the field instead of either of the text
values =(

Is there anything else you can think of?

"Stefan Blom" wrote:

Assuming that REPTotal and PrevYearREP are global variables or bookmarks,
they must be inserted as REF fields in your code:

{ IF { REPTotal } { PrevYearREP } "an increase" "a decrease" }

Also, note that each pair of field delimiters, { }, must be added by
pressing Ctrl+F9.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
I have a form where the user enters the number of reports for the
current
year as well as the number of reports for the previous year. I want to
use
this information to automatically tell the user whether the number of
reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The
field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?


.




.

  #6  
Old April 12th, 2010, 10:45 PM posted to microsoft.public.word.docmanagement
Suzanne S. Barnhill
external usenet poster
 
Posts: 31,786
Default IF statement not working

Have you selected the field and pressed F9 to update it?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"CPelkey" wrote in message
...
Yes, I am using Ctrl+F9 to enter all fields. I have several fields in the
document that all work perfectly well, but none of the If-Then-Else
statements I use seem to work. There must be some kind of syntax error I
am
making, I just don't have the experience to be able to find it.


"Stefan Blom" wrote:

How did you create the starting and closing braces? These must also be
inserted via Ctrl+F9 (or via the Field dialog box of course); otherwise
you
haven't got a working IF field construct.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
Stefan, thanks for your reply!

I tried inserting the references using Ctrl+F9, but now instead of
giving
a
result, it comes back with the contents of the first reference. So
whatever
number is in REPTotal displays in the field instead of either of the
text
values =(

Is there anything else you can think of?

"Stefan Blom" wrote:

Assuming that REPTotal and PrevYearREP are global variables or
bookmarks,
they must be inserted as REF fields in your code:

{ IF { REPTotal } { PrevYearREP } "an increase" "a decrease" }

Also, note that each pair of field delimiters, { }, must be added by
pressing Ctrl+F9.

--
Stefan Blom
Microsoft Word MVP



"CPelkey" wrote in message
...
I have a form where the user enters the number of reports for the
current
year as well as the number of reports for the previous year. I want
to
use
this information to automatically tell the user whether the number
of
reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason,
no
matter what numbers I use, the field ALWAYS displays "an increase".
The
field
is not locked, and I have been updating it after changing the
numbers.

What am I doing wrong?


.




.



  #7  
Old April 12th, 2010, 11:15 PM posted to microsoft.public.word.docmanagement
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default IF statement not working

Hi CPelkey,

Instead of an IF test, try something along the lines of:
{={ REPTotal }-{ PrevYearREP } \# "'an increase';'a decrease';'no change'"}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.

--
Cheers
macropod
[Microsoft MVP - Word]


"CPelkey" wrote in message ...
I have a form where the user enters the number of reports for the current
year as well as the number of reports for the previous year. I want to use
this information to automatically tell the user whether the number of reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?


  #8  
Old April 13th, 2010, 03:12 PM posted to microsoft.public.word.docmanagement
CPelkey
external usenet poster
 
Posts: 4
Default IF statement not working

macropod,

Thank you sooooooo much, it works perfectly now!!

"macropod" wrote:

Hi CPelkey,

Instead of an IF test, try something along the lines of:
{={ REPTotal }-{ PrevYearREP } \# "'an increase';'a decrease';'no change'"}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.

--
Cheers
macropod
[Microsoft MVP - Word]


"CPelkey" wrote in message ...
I have a form where the user enters the number of reports for the current
year as well as the number of reports for the previous year. I want to use
this information to automatically tell the user whether the number of reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?


.

  #9  
Old April 13th, 2010, 03:21 PM posted to microsoft.public.word.docmanagement
Stefan Blom[_3_]
external usenet poster
 
Posts: 4,556
Default IF statement not working

Clever!

--
Stefan Blom
Microsoft Word MVP



"macropod" wrote in message
...
Hi CPelkey,

Instead of an IF test, try something along the lines of:
{={ REPTotal }-{ PrevYearREP } \# "'an increase';'a decrease';'no
change'"}

Note: The field brace pairs (ie '{ }') for the above example are created
via Ctrl-F9 - you can't simply type them or copy & paste them from this
message.

--
Cheers
macropod
[Microsoft MVP - Word]


"CPelkey" wrote in message
...
I have a form where the user enters the number of reports for the current
year as well as the number of reports for the previous year. I want to
use
this information to automatically tell the user whether the number of
reports
has increased or decreased.

REPTotal is the total reports for the current year
PrevYearREP is the number of reports for the previous year.

Here is the IF statement I am using:

{ IF (REPTotalPrevYearREP "an increase" "a decrease") }

I don't anticipate the numbers ever being the same. For some reason, no
matter what numbers I use, the field ALWAYS displays "an increase". The
field
is not locked, and I have been updating it after changing the numbers.

What am I doing wrong?




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.