[Solved] Blank field within a line of multiple fields

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
mrdavie
Posts: 22
Joined: Tue Mar 02, 2010 11:56 pm

[Solved] Blank field within a line of multiple fields

Post by mrdavie »

Am I an advanced user if i use more than the alphanumeric keys and the enter key to write a letter? Just kidding; here's my question.

I forgot how to hide a line containing one merge field that is blank and then I found the answer. I hate forgetting things.

Now I want to supress one field in a string of fields. Example: Line has [title] [firstname] [middlename] [lastname].

Not everybody has a middle name. When it is missing there will be an extra space between the first and last name. I am thinking that the Hidden text field will work but I can't get it to work. HELP!
Last edited by Hagar Delest on Wed Jul 21, 2010 8:33 am, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.1.1
Windows XP Professional Version 2002 SP3
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Blank field within a line of multiple fields

Post by acknak »

As far as I know, OOo has no way to insert a database field only if it isn't empty. Instead, I think the trick is to insert the [middlename] field always, and then insert a conditional space if the field is not empty. If the field is empty, then you don't need the space.

You can try something like this:

1) View > Data Sources; select your table or query so that the data grid is filled in and active.
2) Insert > Fields > Other > Functions, Type: Conditional text
3) Drag the [middlename] column head from the data grid into the fields dialog, and drop it in the Condition entry. It should end up looking something like: [database.table.middlename].
4) Add text after the field to complete the condition: [database.table.middlename] neq ""
5) Enter a space in the "Then" entry. Leave the "Else" entry empty.
6) Click "Insert" and then "Close"
AOO4/LO5 • Linux • Fedora 23
mrdavie
Posts: 22
Joined: Tue Mar 02, 2010 11:56 pm

Re: Blank field within a line of multiple fields

Post by mrdavie »

close but not quite working for me. I can get rid of the space if the field is blank. Actually, I am doing this for the title such as Mr. or Ms. or Mrs. at the beginning of the address. I can get rid of the space if the field is blank but I cannot get the field to display if it is NOT blank.
OOo 3.1.1
Windows XP Professional Version 2002 SP3
mrdavie
Posts: 22
Joined: Tue Mar 02, 2010 11:56 pm

Re: Blank field within a line of multiple fields

Post by mrdavie »

NEVER MIND! I GOT IT TO WORK! There is this thing with OOo Writer where it is necessary to press the Date to Fields button or get the program to go through some type of refresh to get things to work. After entering the conditional information per the instructions above in this thread, I added the field again in front of it. It all works.
OOo 3.1.1
Windows XP Professional Version 2002 SP3
mrdavie
Posts: 22
Joined: Tue Mar 02, 2010 11:56 pm

Re: Blank field within a line of multiple fields

Post by mrdavie »

I know I have cluttered this thread but now I am working on the example you gave above for the middle name. Right now, if there is a middle name everything is fine. If there is no middle name there are two spaces.
OOo 3.1.1
Windows XP Professional Version 2002 SP3
Post Reply