# Problem with IF and option field compiling.

**URL:** <https://www.dynamicsuser.net/t/problem-with-if-and-option-field-compiling/23690>\
**Category:** User Forum\
**Created:** [December 1, 2009, 7:19pm UTC](https://www.dynamicsuser.net/t/problem-with-if-and-option-field-compiling/23690 "2009-12-01T19:19:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lovejazz](https://avatars.discourse-cdn.com/v4/letter/l/5e9695/32.png) [@lovejazz](https://www.dynamicsuser.net/u/lovejazz)\
**Post date:** [December 1, 2009, 7:19pm UTC](https://www.dynamicsuser.net/t/problem-with-if-and-option-field-compiling/23690/1 "2009-12-01T19:19:32Z")

</div>

This won’t compile. Keep getting an error message on the Yes. JobComplete is an Option field with No, Yes the only 2 values on it.

IF (JobComplete = JobComplete::Yes) AND

(JobCompleteDate = 0D) THEN BEGIN

JobCompleteDate:=WORKDATE;

END;

This works but I hate to hard code the 1 in there:

IF (JobComplete=1) AND

(JobCompleteDate = 0D) THEN BEGIN

JobCompleteDate:=WORKDATE;

END;

Thanks in advance,

Greg

Attached is the error message:

END;[2728.untitled.bmp](https://www.dynamicsuser.net/uploads/short-url/oPGKEgoJbJgPMTnyKs3SYiGQNno.bmp) (576 KB)

---

<div class="post-metadata">

**Author:** ![DenSter](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/denster/32/7478_2.png) [@DenSter](https://www.dynamicsuser.net/u/DenSter)\
**Post date:** [December 1, 2009, 7:50pm UTC](https://www.dynamicsuser.net/t/problem-with-if-and-option-field-compiling/23690/2 "2009-12-01T19:50:23Z")

</div>

Your option value is " Yes", with a space before the Yes part. Don’t put spaces between option values. Unless of course that is your intention, and you need to code it like this:

IF (JobComplete = JobComplete::" Yes") AND

The parentheses are not necessary in this case, although I like them there.

So, instead of the optionstring “No, Yes”, change it to “No,Yes” without a space after the comma, and your original code should compile just fine.

---

<div class="post-metadata">

**Author:** ![lovejazz](https://avatars.discourse-cdn.com/v4/letter/l/5e9695/32.png) [@lovejazz](https://www.dynamicsuser.net/u/lovejazz)\
**Post date:** [December 1, 2009, 7:56pm UTC](https://www.dynamicsuser.net/t/problem-with-if-and-option-field-compiling/23690/3 "2009-12-01T19:56:06Z")

</div>

Thanks Daniel.

Greg

---

<div class="post-metadata">

**Author:** ![DenSter](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/denster/32/7478_2.png) [@DenSter](https://www.dynamicsuser.net/u/DenSter)\
**Post date:** [December 1, 2009, 8:22pm UTC](https://www.dynamicsuser.net/t/problem-with-if-and-option-field-compiling/23690/4 "2009-12-01T20:22:06Z")

</div>

no problem, it’s an easy mistake to make (I have regularly made it myself) [:)]
