eddyb2 Posted November 25, 2008 Posted November 25, 2008 Hi all A script takes the user into a layout and enters find mode The user enters their search criteria then clicks the FIND button The FIND button is linked to a script that performs the find and takes the user to a different layout to display the find results The problem I have is if during the find, the user presses Enter/Return - this performs the find and keeps them on the Find Layout rather than the script running and taking the user to the results layout. Is there any way to make Enter/Return to run the script or to disable these keys whilst in Find Mode? Many thanks for any advice!
aldipalo Posted November 25, 2008 Posted November 25, 2008 Take a look at this and check out the find script: View_Edit_Find.zip
bcooney Posted November 25, 2008 Posted November 25, 2008 You almost had it. In our standard Find script, we allow a user to try again or cancel. We have a dedicated Find layout for each table. On it are two buttons, Cancel and Find. The Cancel button's behavior is set to Perform Script "Find" with Exit Current Script and the Find's is set to Resume Script. Our code: //This script requires a script parameter to determine which Find layout to use Allow User Abort Off If (Get (Scriptparameter) = "Cancel"] Go to Layout [$$startLayout] Adjust Window Resize to Fit Enter Browse If [Get (FoundCount) = 0 ] Show All Records End If Exit Script[] End If Set Variable [$$startLayout; Value:Get (LayoutName)] If [Get{ScriptParameter) = "cli" Go to Layout["CLI_Find" (CLI)] End If Enter Find Mode[] Go to Object [Object Name:"find"] //each Find layout has one object named "find" Pause/Resume Script [indefinitely] Perform Find[] If [ Get (FoundCount) = 1 Go to Layout ["CLI_Detail" (CLI)] Else If [Get (FoundCount)> 1] Go To Layout ["CLI_List" (CLI)] Else Go to Layout [$$startLayout] Show Custom Dialog ["No Records Found" ; "Sorry.." //1=Try Again 2=Cancel If {LastMessageChoice) = 1 //Find Again Perform Script ["Find" ; Parameter: Get (ScriptParameter)] Else Show All Records End If
eddyb2 Posted November 25, 2008 Author Posted November 25, 2008 bcooney, thanks so much for this, if i am understanding this correctly you may have just saved me a lot of time. Basically you have 1 single find script that controls the find for each table, right? There goes many scripts for me!! yay! I just have a few questions if you don't mind... 1) In the first part of the script if the paramter passed through is "cancel" you go to layou $$startingLayout, how can you do this if you have yet to define the variable $$startingLayout later in the script? Does it not matter where this is defined? 2) In the next part of the scipt you have If [Get{ScriptParameter) = "cli" Go to Layout["CLI_Find" (CLI)] End If Would you just add else steps in there to define each of the layouts you were planning to use the find script with? 3) What is the object named "find" for - is this because you are using this for multiple layouts so you cannot use go to field? Many thanks again, as I say if I am understanding this correctly it is a big leap in my FM learning curve! Ed
bcooney Posted November 25, 2008 Posted November 25, 2008 Basically you have 1 single find script that controls the find for each table, right? Actually, we have one Find script for the entire system for all tables. The Find button on each form and list view runs Find_Generic script, just with a different script parameter. 1) In the first part of the script if the paramter passed through is "cancel" you go to layou $$startingLayout, how can you do this if you have yet to define the variable $$startingLayout later in the script? Does it not matter where this is defined? Well, you'd never send "Cancel" to the script, unless you're on the Find screen, so you've passed by the Cancel section at least once. Would you just add else steps in there to define each of the layouts you were planning to use the find script with? Yes, this can be an entire if elseif elseif...endif section. 3) What is the object named "find" for - is this because you are using this for multiple layouts so you cannot use go to field? Right!
eddyb2 Posted November 25, 2008 Author Posted November 25, 2008 Thanks again - this is great have just got it running! I have one issue though, not sure where I'm going wrong. When I perform the find if it returns a count of 1 it goes to the detail page. If it returns >1 it goes to the list page. All fine. If it returns no results, I first get the standard FM no result message, I click continue, I then go to my starting layout and it displays my custom dialog. It seems as though it is displaying the standard message before it gets the current record count. How can i avoid the standard message? Thanks
aldipalo Posted November 26, 2008 Posted November 26, 2008 Set Error Capture script step Format Set Error Capture [] // Put as first line of script Options On suppresses FileMaker Pro alert messages and some dialog boxes. If the error result is 100 or 803, then certain standard file dialog boxes are suppressed, such as the Open dialog box. Off re-enables the alert messages. Set Error Capture suppresses normal FileMaker Pro alert messages. You'll find a full explanation under Filemaker help.
bcooney Posted November 26, 2008 Posted November 26, 2008 As aldipalo says, you need a Set Error Capture On step right before the Allow User Abort Off. I missed that because I use a two line subscript that does both, and call that script at the top of each script. In development, my Abort_Control subscript has Error Capture Off, Abort On so I can debug. When shipped, we change the subscript to Abort Off, Error On.
Recommended Posts
This topic is 5839 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now