Thank you for posting.
One straightforward solution is to create a new layout without the next button. When the user runs the Next Record script, they can be directed to the duplicate layout if the current record is the second to last. For example:
If [Get(RecordNumber) = (Get(FoundCount) - 1)]
Go to Layout ["Browse End"]
Go to Record/Request/Page [Next]
You may need to consider how to go back to the original Browse layout and other issues, but this should get you started on one possible method.
TSuki, you are suggesting that I create a duplicate layout called "Browse End" that doesn't contain the "next button" and send my users to that whenever FoundCount=1. I use this technique a lot in my database and the list of layouts is getting pretty long. Is there any way to add the button to a screen as part of a script?
You can't add buttons, but you can use visibility tricks to hide/reveal the button. Frankly, the extra layout seems like an easier approach to use, but since you asked:
You can define a small single row portal with invisible borders and place the button inside the portal. To hide the button, change the value of the field used to relate the current record to the portal record so that the values no longer match and the button will disappear.
Haven't tried that in IWP, but it's worth a try.
Another approach is to create three fields:
1. a calculated container field for the button graphic
2. a container field with a 1 x 1 pixel of the color of your choice entered to refer to if you want the color to display in field 1. (Make all subsequent records copy from the first to keep all populated as if a global field)
3. a calculated text field for the button text
Overlap the two and calculate the fields based on the conditions you desire. When they're both "empty" as in "". They will come back blank and should not display on IWP. If you want the button to display, have it show the text you desire and reference the container field (2). Then script the button to halt if accidentally clicked on by the user in IWP or perform the desired action.
Note: be sure to assign BOTH displaying fields (1&3) the script.
Not elegant I know, but IWP isn't known for it's robust capabilities without a lot of work-arounds. :)