This is possible. You can make a new field that is a "Calculation" field.
There you can mix standard text with values from fields. The text needs to be within quotation marks.
The field names don't. When you use different elements you need to use an operator like &.
I'll give you an example:
FirstName & " " & Lastname
This example combines two fields: FirstName and LastName and has a space in the middle. This space is a text so needs to be between quotation marks. The & operators are needed between the different elements. You have 3 elements, so 2 operators.
When you make a calculation there is a list op operators you can use. There is also a new paragraph operator. ¶ That is used to start on a new line.
A letter could look like this:
"Dear # & Title & " " & LastName & "," & ¶
& "I'm writing you about our offer nr. " & OfferNr & "."
And so on. Once you understand the different elements it becomes quite easy.
Greetings Guy Stevens
Thank you! I realized calculation field was the way to go just after my post. I did not know about all of the syntax though, so that is much appreciated!
This doesn't all have to be made in a calculation field. It can also be made in a new layout, like a print layout that is then later printed or turned into a PDF.
In Layout mode you can simply use the text tool to start typing text.
The areas where you want to enter field data you just go to the "Insert" menu and choose "Merge Field".
There you pick a field from the current table or a related table and you are good to go.
The handy thing here is you don't have to add all the operators etc.
It just depends on what you want to have in the end. If you are looking for a printed report or a mailable pdf. This might be the best option.
I am not familiar with that, but it also sounds useful. I eventually want to output the text (with embedded variable data) to a plain text file. Do you think this would be best achieved with a calculation field with an export script or with this latter layout method?
If you want to end up with a text file then you should definitely use a calc field.
I don't know if you can directly export to a text file. But you might be able to export to a tab text file.
Either that or you copy the text from the field and then manually paste it in a text file. But that might be more work.
I quickly looked it op and you can use the "Export Field Contents" script step to export the value of a field to a text file.
You can also test this manually by right clicking in a field and choosing that option.
Wow, awesome. Thanks!
One more question. Do you know if the text that I would create in the layout text tool, as described above, can then be saved back into a field? The text would be a lot easier to construct and format that way.
I don't think that will be possible.
You really need to set it up right so that it's clear which parts are fixed text and which parts are variable data.
It might seem a little tricky at first. But just start very simple and add stuff as you go. It will start to look complicated after a while. But it shouldn't be too hard.
Okay. That's do-able. Thanks for all the help!
There's a middle ground between straight calculation and layout text with merge fields. The "template" option allows you to type up your "boiler plate" text in a large text field with placeholders inserted to mark the insertion points for data from your database. Then a calculation field can use the Substitute function to replace the placeholders with data from the database. This can allow you to set up a series of records where each record is a different "form letter" that can be used to generate Printed output, emails, PDF's etc that merge the boiler plate text with data from your database.
See this demo file: https://www.dropbox.com/s/6xw8buafjuohncu/MessageTemplateBuilder.fp7
It's in the older file format so you will need to Launch FileMaker and use Open from the File menu to open it if you are using FileMaker 12 or newer.
@PhilModJunk, thank you for this! I will try and model mine after this.