philipcaplan Posted October 9, 2006 Posted October 9, 2006 I want my users to perform a "Find" without them having access to Filemaker's "Find" dialog, for various reasons. I thought it would be a simple matter of giving them a layout where they enter the Find string, with a button which when pressed triggers a script which performs the Find out of their sight. But I can't seem to get it to work. Using FM8.5. Any help would be appreciated.
BobWeaver Posted October 10, 2006 Posted October 10, 2006 Make sure the field that holds the find string is defined as global. Then, your script should simply be as follows: Enter Find mode[] Set Field [someField;globalSearchString] Perform Find[] In both the enter and perform find steps, make sure the "specify find requests" option is unchecked.
philipcaplan Posted October 10, 2006 Author Posted October 10, 2006 Hi bobweaver That seems to work perfectly. Thanks! Now for the next step I'm stuck at! : I need the user to be taken to "Layout 1" if a single match is found (with the found record showing), "Layout 2" if more than one matches are found, or "Layout 3" if no match is found. Could you kindly give me the script steps for the full script needed to achieve this? Many thanks. PHILIP CAPLAN
BobWeaver Posted October 10, 2006 Posted October 10, 2006 Add a "Set Error Capture[on]" step to the beginning of the script so that you won't get an error message if no records are found Then add the following steps to your script after the Perform Find: Go to Layout[original Layout] Go to Layout[Choose ( Min(2;Get ( FoundCount ) ) ; "Layout3" ; "Layout1" ; "Layout2")] You shouldn't really need the first "Go to" step, but I've noticed a bug in FM 8.5 that prevents this from working if The Go to Layout by calculation step appears immediately after the find.
philipcaplan Posted October 10, 2006 Author Posted October 10, 2006 (edited) Hi again bobweaver Many thanks for your speedy reply. I tried what you said, and it worked except that at the end it didn't 'redirect' to the appropriate Layout 1, 2 or 3. It just stayed on the 'original layout'. I am attaching a screenshot of the script as I entered it, in case I have mistyped anything. I'd appreciate your further advice, although as it's now nearly midnight here in the UK, I probably won't be able to look at it until tomorrow evening. Thanks again. PHILIP CAPLAN NOTE: I've just realized that the attached screenshot shows the last-but-one-step as "Go to Layout 3" -- I did that as a test, and it worked as showing that the script was getting to that point. But I really have "Go to original layout" at that point, and that's where it stays!! Edited October 10, 2006 by Guest Silly mistake!
BobWeaver Posted October 10, 2006 Posted October 10, 2006 Make sure you change the formula I gave to the exact names of your layouts. I didn't have spaces in "Layout1" "Layout2" etc. Try "Layout 1", "Layout 2" or whatever the actual layout names are. Also, make sure that you are using the "Layout Name by calculation" option, and not "Layout Number by Calculation."
philipcaplan Posted October 11, 2006 Author Posted October 11, 2006 OK. Obviously I hadn't noticed the lack of spaces in Layout1, etc. I changed the names of my layouts so they match that, and the script now gets to the end. Hooray! But it always takes the user to Layout2, even when showing 'Found' as 1 or 0 (as well as 2) in the Status Area, and of course it should go to Layout1 and Layout3 respectively in those cases. Awaiting more help !! : ( Sorry
BobWeaver Posted October 11, 2006 Posted October 11, 2006 It was doing that to me too. It appeared that the calculated goto layout doesn't work correctly immediately after a find. That's why I inserted the extra Go to original layout step between the find and the calculated Go to. That fixed it for me. It appears to be a bug in version 8.5. I will report it to FMI as soon as I find the bug report link. You could also just try the following script: if [Get(foundcount)=0] ...Go to Layout[Layout 3] else if [Get(foundcount)=1] ...Go to Layout[Layout 1] else ...Go to Layout[Layout 2] end if
philipcaplan Posted October 11, 2006 Author Posted October 11, 2006 Right! Now I've got the script working. Thanks for all your help, bobweaver. PHILIP
Recommended Posts
This topic is 6620 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