This is part of my post dd 16 05: 'Tweak your script to show one record if one record is found, what to do if no records, what to do if multiple records etc.'
Start your script with 'Set Error Capture - On'
It will suppress the FM error messages (called error trapping) and stores the error number in memory temporarily.
Use this script step whenever you want to capture a FM generated error and perform your own sequence of steps.
After your perform find you can go different ways, depend on the result.
Add a few if statements, after your perform find scriptstep, to tell FM what to do when....
1. If no record found the error number is 401.
The scriptstep will be:
If (Status(CurrentError) = 401
Show Message ('No records were found')
Provide buttons to go to browse or search again, and use the
Status(CurrentMessageChoice) to act on that...
This function returns a number corresponding to the button clicked in an alert message displayed by the Show Message script step. Returns 1 for the first button (by default, labeled OK), 2
for the second button (by default, labeled Cancel), and 3 for the third button.
Just change the labels in something you like, f.i. Searh again and Stop.
Make an if statement for both choices
If Status(CurrentMessageChoice)= 1
Goto layout (your layout)
Enter Browse mode
If.......= 2
Goto layout (your search layout)
Enter find mode
2. One record found
If (Status(CurrentFoundCount) = 1
Go to layout (the layout with the info you want)
3. More than 1 record found
If (Status(CurrentFoundCount) > 1
Go to layout (a layout showing the records in listview), from that point you can direct the user to the record of choice by providing a button that goes to the single record or a given layout from that record.
This is a rough approach but will give you a start to play with the function and scriptmaker.
Best is to write down in plain english what you want and look for functions that can do the job, rest is putting them together or moving around untill it works....
or not....
HTH