| View previous topic :: View next topic |
| Author |
Message |
a1runnr General User

Joined: 08 Jun 2006 Posts: 17
|
Posted: Fri Sep 15, 2006 3:55 pm Post subject: Help with conditional text |
|
|
Howdy
I am trying to find a way to create a prefix to names in a form letter. And have not had much luck as yet. Any pointers would be appreciated.
I am using 2.0.3 in XP, using base as the data source.
If the record type is F, prefix should be Ms. followed by the lastname.
If the record type is M, prefix should be Mr. followed by the lastname.
If the record type is D, prefix should be Dr. "
If the record type is H, prefix should be Honor "
If the record type is "", prefix should be null "
etc for other record types.
Thanks in advance for suggestions.
tommy |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Sun Sep 17, 2006 12:39 pm Post subject: |
|
|
| Quote: | If the record type is D, prefix should be Dr. "
... | I don't know what you mean by those bare quotes, but in any case, you can't really express all that in one go. You can only make each one a hidden paragraph with the given condition.
The structure would look something like this:
| Quote: | <Hide if Record_type != "F">Ms. <DataSource.Lastname>¶
<Hide if Record_type != "M">Mr. <DataSource.Lastname>¶
<Hide if Record_type != "D">Dr. <DataSource.Lastname>¶
<Hide if Record_type != "H">Honor <DataSource.Lastname>¶
<Hide if Record_type != ""><DataSource.Lastname>¶
... | Those things in <>s are fields and don't give the exact syntax. |
|
| Back to top |
|
 |
a1runnr General User

Joined: 08 Jun 2006 Posts: 17
|
Posted: Sun Sep 17, 2006 6:57 pm Post subject: |
|
|
Oh nuts, I was afraid of that being the case.
Thanks
tomy |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Sun Sep 17, 2006 7:06 pm Post subject: |
|
|
I think acknak is on the right trail but I believe in a single paragraph you could use 4 Hidden Text fields, one after the other, to get the desired result. The null item would be the result of the 4 other fields.
It's late so I have not tried this but part of the Hidden Text will probably be a space after the title. As in "<Title+Space><LastName>" because you don't want a null item preceded by a space. |
|
| Back to top |
|
 |
foxcole Super User


Joined: 19 Jan 2006 Posts: 2771 Location: Minneapolis, Minnesota
|
Posted: Mon Sep 18, 2006 6:43 am Post subject: |
|
|
| JohnV wrote: | I think acknak is on the right trail but I believe in a single paragraph you could use 4 Hidden Text fields, one after the other, to get the desired result. The null item would be the result of the 4 other fields.
It's late so I have not tried this but part of the Hidden Text will probably be a space after the title. As in "<Title+Space><LastName>" because you don't want a null item preceded by a space. |
I didn't suggest hidden text fields because I'm unfamiliar with mail merge. Am I to understand that they'll work in a mail-merge document the same way they work in a standalone or sub-document and master document? That's cool!
I'm assuming the record type is a character code in the database, and that character would be pulled into a variable in the letter document, then examined and processed---or is it possible for the hidden-text condition to look at the database code directly? _________________ Cheers!
---Fox
WinXP Pro SP2, OOo Portable 2.3.1, OOo local 2.4 RC4
New OpenOffice forum: http://user.services.openoffice.org/en/forum/
Manuals: http://documentation.openoffice.org/manuals/index.html |
|
| Back to top |
|
 |
a1runnr General User

Joined: 08 Jun 2006 Posts: 17
|
Posted: Mon Sep 18, 2006 7:11 am Post subject: |
|
|
I think the easier process would be to look directly at the base record and then act accordingly. I have that working in several other areas I'm playing with.
tomy |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Mon Sep 18, 2006 7:41 am Post subject: |
|
|
Another approach, which is the way I try to go, is to do this in the database. Either convert to a "Prefix" or "Title" field (I.e. change the code letters to the actual title string), or set up a view that converts the codes to a string using another table. I think it seems cleaner to do your merge using simple fields (possibly from a complex query) rather than building a lot of "intelligence" into the merge document. Any of that processing you can do at the database level will be usable by anything that touches the database. The work you do in the merge document will have to be repeated if you need it again.
PS: Before you run off and try this, there are some reported problems doing conditional fields from queries or views (as opposed to direct to a table). I expect it will be fixed soon, but better do a small test first. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Mon Sep 18, 2006 10:48 am Post subject: |
|
|
foxcole,
It's no longer late at night so I tried what I suggested and it worked fine.
I used the Bibliography/biblio table where I temporarily put F,M,D or H in 4 of the records under the Type field. In my document, between "Dear"<a space> & <Identifer> I insert 4 consecutive Hidden Text fields with Conditions like Bibliogrphy.biblio.Type NEQ "F" with the Hidden texts like "Ms. " (note the space).[/code] |
|
| Back to top |
|
 |
a1runnr General User

Joined: 08 Jun 2006 Posts: 17
|
Posted: Mon Sep 18, 2006 7:25 pm Post subject: |
|
|
Yep - I agree with the adding of another table with those prefix and do a hidden pp. That works for me. Thanks.
Oh, now that is interesting :: I will have to try the four conditions as you have found that works. I did not try that as I would of thought the next condition would of over rode the previous test. I guess logic is not my strong area
Thanks Yall. I will play and learn.
tomy |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Tue Sep 19, 2006 11:09 am Post subject: |
|
|
a1runnr,
Note that I'm using a Hidden Text field which is not an If,Then, Else type as is Conditional Text so the conditions do not "step" on one another. |
|
| Back to top |
|
 |
a1runnr General User

Joined: 08 Jun 2006 Posts: 17
|
Posted: Tue Sep 19, 2006 5:50 pm Post subject: |
|
|
JohnV
Oh, so using that process - each test is standsalone. Thanks for the pointer, This should be easy to do.
Thanks
tomy |
|
| Back to top |
|
 |
foxcole Super User


Joined: 19 Jan 2006 Posts: 2771 Location: Minneapolis, Minnesota
|
Posted: Tue Sep 19, 2006 8:31 pm Post subject: |
|
|
| a1runnr wrote: | JohnV
Oh, so using that process - each test is standsalone. Thanks for the pointer, This should be easy to do. |
Yep, regardless of what kind of document or process includes the conditional text, the condition works. Each hidden field is given one condition, and that is to hide the field if the condition is NOT met.
So, for example, your title field of Ms. will *hide* if the variable is NOT Ms. By negative logic, if the field *is* Ms. the title field displays. _________________ Cheers!
---Fox
WinXP Pro SP2, OOo Portable 2.3.1, OOo local 2.4 RC4
New OpenOffice forum: http://user.services.openoffice.org/en/forum/
Manuals: http://documentation.openoffice.org/manuals/index.html |
|
| Back to top |
|
 |
a1runnr General User

Joined: 08 Jun 2006 Posts: 17
|
Posted: Wed Sep 20, 2006 7:03 am Post subject: |
|
|
Thanks for the help.
tomy |
|
| Back to top |
|
 |
|