If you script the action that takes you to the layout in the first place, yes.
Define a global text field, gLayoutName.
In every script that takes your user to this layout, add this script step:
Set Field [Yourtable::gLayoutName; Get(layoutName)]
Before you use Go To Layout or other script step to switch layouts.
Then your "return" script will be a single step:
Go to layout [Yourtable::gLayoutName] // Use the "Specify layout name by calculation" option
You can even place this global field on top of a blank button, group the two objects and set them up as your button to go back. Now that button will display the name to which this script will return the user.
Wow. What a great solution. Even I was able to implement it, and it works perfectly.
Thanks very much. I will give it a try.
I had earlier used your guidance for a return button, and it works great on all my layouts.
But, have a question about returning to a search layout.
I have a specific search layout from one table. Found records are displayed fine. There's a button on the layout that takes the user to the specific found record being viewed. Works fine.
However, the return button on the found record layout takes the user back to the previous search layout but clears the previous found set and makes the user perform the find again.
Is there a way for the return button to take the user back to the found set?
I tried using an If function that says if it returns to the search layout to perform find, but can't figure out how to tell it to perform the last find again.
I'm assuming here that the find criteria were entered by the user into local fields and that no other find by the user or a script hasbeen performed...
If you want to automatically return to find mode and also display the criteria last entered to perform a find, use Modify Last Find instead of enter find mode.
Oops -- I forgot to mention in my earlier post that I had also tried Modify Last Find, which did not work, in the return script.
You mentioned that "if a script has been performed." Yes, a script is performed to take the user from the search layout to the record layout.
I presume running that script dumps the find criteria from the search layout.
What I said was that if "no other find has been performed". That find could be perfomed by a script or by hand.
Filemaker "remembers" the criteria used in the most recent find. The next find to be performed will supplant this criteria--which is why I inserted that qualifier.
Are the fields on your search layout local fields or global fields that a find script uses to construct a find and search the database?