Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 8244 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I've seen postings on this, but never a solution...

Is it possible to (easily!) script multiple find requests using values obtained through checkboxes?

For example, a database of critters is classified by type:

cat

dog

bird

snake

mouse

I'm generating a report. I would like the user to specify (check) through checkboxes which critters he/she wants to include in the report, then script a find to isolate just those records.

I (more or less) understand scripting multiple find requests, but translating the "checkboxed" field contents to multiple find requests loses me.

Any suggestions before I try to do this the long way would be much appreciated...

Posted

Set up a global field, gCount.

Set up a global field, gFind.

Format gFind with checkboxes / the "critters" value list, and put it on a layout with a Search button and a Cancel button. The Search button script:

Enter Find mode [ ]

Set Field [gCount, PatternCount(gFind, "

Posted

Here is the simpleton's method.

Say you already have a Critters text field that defines the animal. Then create separate global text fields for each kind of critter and format each field with a checkbox and value list containing just the value for that critter. This example has Cat, Dog and Mouse and here's your script:

Show Message [buttons:"OK","",""; Data: "Click the critters you want to find"]

Go to field [Cat]

Pause/Resume Script[ ]

Enter Find Mode

If [not(IsEmpty(Cat))]

Set Field [Critters, Cat]

End If

New Record/Request

If [not(IsEmpty(Dog))]

Set Field [Critters, Dog))]

End If

New Record/Request

If [not(IsEmpty(Mouse))]

Set Field [Critters,Mouse))]

End If

Perform Find

Clear [Cat]

Clear [Dog]

Clear [Mouse]

Of course if you have lots of critters, this will be a pain to script. And if your critters mutate you'll need to change the fields and the script - bad practice I know. Let's just say, pace Fitch, that I find this much easier than working out a Position-Middle-Length-Position type thing.

tongue.gif

Posted

Addendum to simpleton's method:

1) Put your New Request after the If[ ], so you'll have fewer extraneous requests.

2) Instead of Clear(), use Set Field(""), so it doesn't matter what layout you're on.

3) You may not want to clear, you may want to display the search criteria in the header or something.

4) Sure, my method was harder to work out, but now it's all done, so just copy and paste it! That will be less work than setting up a global field / value list for every critter, not to mention requires no additional maintenance if the value list changes!

5) The "non-simple" method is how many lines longer? Three. And how much longer is it when you add a fourth critter? Zero. And how many critters in aubrey's example? Five.

Alison, this is not meant as a slam on you or your script. In fact, I absolutely agree with you that sometimes it's silly to use a sledgehammer to kill a gnat. It crossed my mind that that might apply here, but what can I say? I got into it! cool.gif FWIW, my simpleton solution would probably have been to just hard-code the names into the script:

If [PatternCount (gFind, "cat")]

New Record/Request

Set Field [Critters, "cat"]

End If

etc.

That way you only need the one global gFind, and for additional critters you just add those four steps to the script as needed. For just a few critters I'd say, fine. But... ten or twenty? Fuhgettaboutit! shocked.gif

Posted

quote:

Originally posted by aubrey:

I've seen postings on this, but never a solution...

Is it possible to (easily!) script multiple find requests using values obtained through checkboxes?

For example, a database of critters is classified by type:

cat

dog

bird

snake

mouse

I'm generating a report. I would like the user to specify (check) through checkboxes which critters he/she wants to include in the report, then script a find to isolate just those records.

I (more or less) understand scripting multiple find requests, but translating the "checkboxed" field contents to multiple find requests loses me.

Any suggestions before I try to do this the long way would be much appreciated...

If you have to use only one field for find then why bother to create an find script. Instead use relationship. I supose your criteria field is an global ( it doesn't matter if it isn't)

So create an relationship let's cal it "Criteria" from yourCriteriaField to actual field containing single ( or even multiple values from criteria list)

Select any criteria number you want and

GTRR ["Criteria", show only related]

That's all

HTH

Dj

[ April 12, 2002, 12:07 AM: Message edited by: dj ]

Posted

Otherwise...

code:


You'll need an global number field counter and an global text field temp.

First present the user the layout for sellecting critters to search for. Three butons:

Cancel, Find More..., Find (default)

deal with "cancel2 in appropriate way also check for empty selection

Script for "Find more.." button

Show Message[ "Enter additional criteria to critters then press "enter"
Posted

Doh! crazy.gif GTRR is of course the way to do this! Dj hit the nail on the head. How simple is that!

Of course, we're assuming you only care about finding critters by name, no additional criteria like date, cost, etc. If so, Go to related record is the one!

Posted

Just to amplify on Dj's suggested use of a relationship...

You have a field for critter_type. Create a global text field critter_types_for_report and put it on a Find By Type layout along with some instructions to "Choose the type(s) desired and then press Continue." You probably already have a report layout. Also create the relationship "Critter Report Relationship" from critter_types_for_report to critter_type.

Now create a script like this:

Go to Layout [Find By Type]

Pause

Go To Related [show,"Critter Report Relationship"]

Go To Layout [Report on Critters]

Page Setup

Print

etc.

Go to Layout [original layout]

+++++++++++++++++++

Hope that helps a little more! -- Mark

  • 2 weeks later...
Posted

Thanks to all for the suggestions. DJ's related records scheme was a great thought - however I DO have multiple fields I am searching on. Fitch's script (looping through the checked variables and setting new find requests for each) works great, but here's the clincher... I need to do the find using checkboxes in MULTIPLE fields. For example, being able to find on Critters (cat, dog, bird), Color (blue, green, red), Sex (male, female), etc.

(my actual database needs to search on about 8 fields with 2 to 6 possible values each - too much to try to hard code)

This seems to get ugly quickly, with multiple find requests on multiple fields. I can customize Fitch's script for each field/value list, but how do I link them so that they are searching off eachother? Modify last find does not seem to cover this (due to the multiple find requests in each field).

Seems like there should be a reasonable way to do this - maybe I am still missing something?

Posted

Erwin, your point is well taken, however, in this case we're talking about finding all cats AND all dogs, so just checking the check boxes in Find mode is not going to do it. However...

...now it turns out that there's considerably more going on, so aubrey, it sounds to me like you should not format your fields with checkboxes after all, but rather use pop-up lists for Critter, Color, Sex, etc. Use the actual data fields, not globals. Make the Find screen a list layout, and put buttons that allow the user to add/duplicate/delete requests. If "New request" is too confusing, change the button label to say, "Also find" or "Find more..." or something.

Give your users 5 minutes of instruction and you're all done. Explain to them that this way is much more flexible, because what if they want to see all red cats and purple dogs? You couldn't do that with checkboxes, you'd end up with red and purple cats, red and purple dogs.

You could even show them... how to Omit! Or use a range! Duplicates! Booleans! Or not.

Posted

Hi,

I'm sorry Tom but it will work. At least, I hope Aubrey has a 'new' record button in his application (somewhere) ...

* Find button to get into find mode

* Click checkbox Cats (can even be combined with color)

* New button (gives a new find empty window, to perform the AND over CB's)

* Click checkbox Dogs (can even be combined with color)

* Enter

Tell me, what's wrong here ???

Posted

I'm not trying to start a pissing match, Erwin, I was just pointing out that your first post did not address the problem as originally stated. If you read past the first sentence of my post you can see that, now that aubrey has revised his requirements, I'm agreeing with you! And you agree with my suggestion to add a "new request" button. So nothing is wrong.

Wait, hold on... I stand by my recommendation to NOT use checkboxes on the find screen. Use radio buttons or pop-ups. Checkboxes will lead the user to expect that checking "cats" and "dogs" will find cats AND dogs. Instead FileMaker will attempt to find all critters that are a combination of cat and dog. I.e., zero will be found.

Posted

Ok, sounds fine with me. By now Aubrey should have very a good idea how and what to start scripting ... smile.gif

BTW, will you be at Devcon 2002 ?

Posted

OK - after all your wonderful suggestions, I think I finally reverted back to the most primitive way to query a database. Erwin, I think you are probably right that I should simply take the user to a blank find screen to input the parameters. However, with multiple find requests this gets to be a bit complicated for the user. Fitch's suggestion of using radio buttons/pop-ups and a bit of training on how to setup multiple find requests is also a good thought, but I'm not sure it is feasible with these end-users (lawyers - it could get ugly!). Plus, with the large number of query fields and value choices, multiple find requests turn into a big ugly matrix (I'm STILL not sure I can get the proper records selected when I attempt these finds MANUALLY).

SO... I opted to add in a new "marker" field for each find field. I then go through each find individually and "mark" the found set records in the marker field. After all the individual finds are complete, I do a final find on records with all marker fields marked. I know, I know... this is very cumbersome and adds a bit of time to the report generation, but for the size of the database and the report use the added time is worth the flexibility in the reports.

Thanks to you both - I appreciate all the advice on this.

(and, by the way... I'm a she, not a he!)

This topic is 8244 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.