You can use the OnRecordLoad trigger on both layouts to run the same script:
If [ Table::field = 1 ]
Go to Layout ["Layout for when value is 1" (Table) ]
Go to Layout ["Layout for when value is not 1" (Table)]
Then the script performed by your button can just use:
Go to Record/REquest/Page [next]
And there are nay number of ways to get a small graphic to use as the arrow icon to click for this.
I often just use the following button label text:
|<, <, > , >|
as the buttons lables for Go to "first" , "previous", "next" and "last" records.
Thanks PhilModJunk! I managed to create the scripts and I also like the idea for the buttons
Hi PhilModJunk, I notice that I have an additional "challenge" now :
Is it also possible to force the layout for the print?
Thanks in advance for the additional input!
Please explain what you mean by "force the layout for the print".
Well, exactly the same as what the script you gave me does.
I have i.e. 50 records for my main table. 40 of them have a field flag = 0 and should be shown and printed using Layout A and the 10 others have the field flag = 1 and should be shown and printed using Layout B.
I used your script to navigate from one record to another and they show perfectly in the correct layout but one I want to print, FM prints the 50 of them using the layout of the actual record that is shown.
Using this script, you'd have to generate a separate print job for every record using the current record option.
To "batch" the print jobs, you'd need to perform a find for all records where flag = 0, print them using records being browsed and then perform a find for all records where flag = 1 and print them.
If each record represents a different page of a single report, you'd need to use Save As PDF to generate a PDF of this report saving a PDF of each record one record at a time. There's an append option that allows you to append a new PDF to the end of an existing PDF so this allows you to "stitch together" multiple reports from different layouts.
I just checked those commands in the scripting and it looks fairly easy to make! I should be able to work this out from here
One additional question, related to the button : do you - as with the "navigate to next/previous record" - also here have a preferred "text button" you use to define a printer (print all & print active record) or do you use an icon for this?
I don't really have a preference. I've used the word "print" most often, but now that I've been playing around with the Paint.Net application's ability to produce transparent png images, I'd probably look for a dingbat font of a printer and use that program to produce a printer icon if I were to do that now.
Thanks for your input!
Small question for the printing script : what type of commands should I use to search for the flag and select only those for printing?
I have already tried a couple of them but it seems that it always prints all the record like the search was not taken into account.
Thanks in advance for your input!