Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    complex fieldcode statement (WordXP SP3)

    Im trying to place some code in a fieldcode but dont know the syntax. Can you do an If elseif statement in a fieldcode?

    heres the logic:

    If old data exists print the old data as plain text and if new data exists print the new data as bold text.
    if no old data and just new data exists print the new data in plain text.

    can/how i place this in a fieldcode?
    many thanks
    diana

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: complex fieldcode statement (WordXP SP3)

    There is an IF field in Word, the syntax is

    { IF condition, value-if-true, value-if-false }
    for example
    { IF bmk1<>"", "This bit of text", "Other bit of text"}

    The values in quotes can be quite complex, including tables, graphics etc., but I don't know how to achieve different formatting depending on the result. Maybe <!profile=Macropod>Macropod<!/profile> will turn up with one of his incredible nested solutions.

    StuartR

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: complex fieldcode statement (WordXP SP3)

    You don't tell us where the new and old data is coming from so I assume you have bookmarked this somewhere else.
    This field nesting appears to work for me when the last ref new field is bolded
    {If {ref old}="" "{ref new}" "{ref old} {ref new * mergeformat}"}
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Hi Diana,

    In Word fields, you can create an 'elseif' test by embedding another IF field in the first one. For example, you could code a set of fields like:
    {IF{Condition1}=TRUE "Condition1 True Response" {IF{Condition2}=TRUE "Condition2 True Response" "Condition2 False Response"}}

    How complex do you want to make it? Word can handle up to 20 nested IF fields! You can also incorporate AND and OR tests. The syntax is pretty much explained in <post#=365442>post 365442</post#>, where you'll find some examples of nested IF fields under the heading 'Calculate Horizon Distances Using Word Fields'.

    However, the example you gave may not require any more than a single IF test. For example, if the OldData and NewData values exist as bookmarks, then the following field coding would work:
    {IF{OldData}= "" {NewData * Charformat} "{OldData * Charformat} {NewData * Charformat}"}
    In the above example, using the Charformat switch and formatting the first character of each field reference to suit is all that would be required.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    In the Data source the old data is also stored in a column.

    after about a day or 2 - I managed to work out the fieldcodes...see attachment

    many thanks
    Attached Images Attached Images

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    I've since got further information from the user. they want to test on 2 conditions & I dont know if you can add this into the fieldcode.

    If the matter is "Y" - make the text bold "Description"
    Otherwise If OldDescription not equal empty text then "OldDescription" to be Plain text, "Description" to be bold text, Or "Description" text to be bold.

    Heres my attempt at the field code>>>what do you think?

    many thanks Diana
    Attached Images Attached Images

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Stewart

    the different formatting can be set - in the fieldcode use the switch * CharFormat - and the apply the formatting required to that fieldcode with the switch.

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    just to add more complexity ( i think it is causae I dont use fieldcodes)

    my conditions are :

    If New Matter = "Y" then type '- new matter (in bold) OR If new Matter = "<no code>" then type '- new matter (in bold)
    OR if OldDescription <> "" then old decription in plain text and description text in bold, otherwise description text in bold.

    Can I add this to my If fieldcode?

    Diana

  9. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Hi Diana,

    It's certainly possible to test on multiple conditions, but I can't tell from your posts what the conditions are or how the test results are to be applied.

    In <post#=517011>post 517011</post#> you describe the test as:
    If the matter is "Y" - make the text bold "Description"
    Otherwise If OldDescription not equal empty text then "OldDescription" to be Plain text, "Description" to be bold text, Or "Description" text to be bold.
    This implies that "Description" is always bold and "OldDescription" is always plain. Is that correct? If so, you don't need an IF test at all.

    Then, in <post#=517014>post 517014</post#>, you describe the test as:
    If New Matter = "Y" then type '- new matter (in bold) OR If new Matter = "<no code>" then type '- new matter (in bold)
    OR if OldDescription <> "" then old decription in plain text and description text in bold, otherwise description text in bold.
    I don't understand how you can get a situation where:
    If new Matter = "<no code>" then type '- new matter (in bold)
    would apply. Surely, this is an empty result!? In any event, it seems that "NewMatter", if it exists, is always a bold "Y". Or am I missing something?

    Perhaps if you explain the test and the values being tested more along the lines of:

    IF NewMatter = "Y" Then
    Description (Bold)
    ELSE
    Description (Plain)
    END

    or

    IF NewMatter = "Y" OR NewMatter = "" Then
    NewDescription (Bold)
    ELSEIF OldDescription = ""
    NewDescription (Plain)
    ELSE
    OldDescription (Plain)
    NewDescription (Bold)
    END

    it would be easier to see what you're after.

    Finally, it appears from the examples you've given that you've formatted some whole embedded fields in bold. In that case, you don't need the Charformat switch.

    Cheers
    PS: When replying, it's best to reply to a post from the person you're trying to interact with - some of your's have been replies to yourself, which means that whoever you want to act on them won't receive them to act on ...
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #10
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Apologies I was unclear & also noticed i did a typo ie i wrote bold when i meant plain....so here goes...

    If New Matter = "Y" or New Matter = "<no code>" then
    after the data newMatter type the text - "- New Matter" (format in bold)
    Else
    do nothing
    End if

    If New Matter = "Y" or New Matter = "<no code>" then
    New Description - format as bold
    ElseIf OldDescription =

  11. #11
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Hello

    Thankyou for your sample document. Using your sample Im getting closer to the resolving it.

    Ive managed to simplify it further however i still dont get the syntax. Ive added an attachment of the fieldcodes logic

    many thanks
    diana

  12. #12
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    hello

    using your sample i managed to get in working. please see attached document with the fieldcodes.

    many thanks for your help
    diana :-)

  13. #13
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Hello

    Yes thats much easier & simpler thankyou. Gosh Ive learnt alot about fieldcodes :-)

    cheers diana

  14. #14
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Hello

    I have another requirement and it maynot be possible using fieldcodes.
    If I have old values. And I have new values. The 1st 3 values are the same. But d & e are new. They just want d & e bold.

    old value column:
    a
    b
    c

    new value column::
    a - same as the old value therefore plain text
    b - same as the old value therefore plain text
    c - same as the old value therefore plain text
    d - this is new therefore bold this text
    e - this is new therefore bold this text

    Can I use a Compare field>? will this work in a field code or is it getting to complex.

    many thanks diana

  15. #15
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: complex fieldcode statement (WordXP SP3)

    Hello

    I did a test merge with the new fieldcode.
    if the old value has 'a b c'
    and the new value has 'a b c d e'

    the result is the new value displays all the value bold ie 'a b c d e'

    when i need the new value that has the same value to display in plain ie 'a b c' & only the different values bold ie 'd e'
    pls see my screen example.

    Can this be done in a fieldcode?
    many thanks diana
    Attached Images Attached Images

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •