Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Box with a script behind it

Status
Not open for further replies.

gaift

Programmer
Jul 10, 2006
74
US
I was working on a database and wondered if i can make a field that will have one check box, what i want this to determine is
that if this box is check i want this record to be omitted if it is not checked then do not omit the record.

The purpose of this check box is to allow the user to select the records that they want to view so what i will have is a script to omit the selected records and then show only the omitted records (as JEANW had suggested).

So the question is: How can i tie the check box to a script so i can get a flow of control to check "if checked select record if not do not select record.
 
Your post is exactly the script:

Let the user check the records.
Then your script can be something along these lines:

Enter Find Mode
Set Field (yourTable::yourCheckboxField;yourCheckValue)
Perform Find
# This will find all the checked records.
If you want the user to 'see' the found set, put here some redirection for no records, 1 records, to a view/list layout etc.
Not really necessary because you check at least one record, it's just a good habit....
If ou want the user to see the 'not checked records' take the show omitted script step.

You can make a loop script to clear the checkbox after the find.

It depends how your structure is to have the 'point' where to clear the checkboxfields again, so they'll be ready for the next search.
 
im still a little confused on how filemaker will be notified to omit a record that is "checked". I can write the script that omits the records but im still unsure of how to let filemaker know that the records with the check selected are the ones that i want to omit so it view the checked records.

Basically i need to link the check mark to filemaker as a signal that this is a record i need to omit.

How do i make this possible
 
There are 2 ways to find records.

Or you do a search to find records with specific data.
This will give you a found set of records with the specific data.

Or you do a search for data that you know is not in the records you want to find.
FM will omit all the records without the data.

If you ask now to show the omitted records, FM will give you a found set of omitted records, the records without the asked data....

In your case.
Make a search for the checked records, FM will give you a found set with records where that field is checked.

If you want the records without the checked field, do the same search (the one for the checked field), but ask for the omitted records, FM will give you the found set of records without the checked records.

Bottom line:
1) you check records, search for checked records = found set with checked records.
2) you check records, search for (checked field empty) = records without checked field.
3) you check records, search for checked records and omit those = found set without checked records
4) you check records, search for checked records and omit those and ask to show omit records = found set with checked records.

Best way to understand the mechanics is to make a little file with 5 records and make several scripts with combinations of yes/no omit.
Follow your logic as to find records and see if FM follows your logic.
 
What i mean is what kind of field should the box that signifies if a record is being selected or not selected be
should it be a calculation.
I figured out how to isolate records taht the user may want to isolate, im just trying to figure out how will a checkbox
noftify filemaker that thats a record that i want to isolate.

 
The kind of field is not important, ít's the data in it.
You can make a 'special' Exclude field linked to a Yes/No valuelist with No or Yes as default value and make it radiobutton.
This will toggle between yes/no, if the label for that field is 'Omit ?'

Or just a Yes valuelist withthe field formatted as checkbox, checked will be 'Yes', not checked will be nothing (empty).

Or you could use a text field with default value 'Include criteria in result'. With a script you could toggle between this value and 'Remove criteria from result'.

FM will look for specific data that you, the developer linked to omit or not.

You can link those fields to a script that is triggered with a button on your search screen.
Something along these lines (for the last example)

#Make sure to check taht the mode is Find before taking this action.
If(Get(WindowMode)=1
# An omitted request will exclude the specified criteria from the search results
Omit Record
#Because usng the Omit Record step is a toggle for the Omit checkbox you need to toggle the feedback in the in the Exclude field. It will show the user whether the data is being included or excluded.
Set Field (yourExcludeField;
Case( yourExcludeField ="Include criteria in results";
"Exclude criteria from results"; "Include criteria in results"
)
End If

Basically, a well designed Search Routine has 8 scripts, 4 buttons and 2 layouts.
This together will give you a nearly waterproof searchsystem.
 
On this topic again, sorry for my ignorance, but
if i were to use the check box option how would i link it to the script, for example i would have a field labeled:
Select Record For Editing (with a checkbox option next to it),
does filemaker return 1's or 0's such that a check in the box would = 1 for its value, and a blank check box be 0 for its value.

This way for the script i can go through all the records doing this in code:

//pseudo code
for (i= firstRecord; i < totalNumRecords; i++) {
if(checkbox(record) == checked) {
omit(record);
}
}

show ommitted records;

/*esentiall the methods omit and show ommitted records dont
exists i would actually have to make a seperate array
but this way you get the idea
*/
//end pseudo code

i am having trouble applying this algorithm in scriptmaker for filemaker pro 8.

right now i see something like
Loop
(some method selecting the current record)
if(current records checkbox is checked)
omit record
end if
(an increment that will switch to next record)
Exit Loop If (next record > total number of records)

im having trouble filing in the pseudo code
 
If you use a checkbox formatted field,
Checkbox Set will display value list items as checkboxes. Users can select multiple values for a field.

It is a 'format' of a field, the values in the field (if there are more than 1) will be as a return delimited list.

So if you use just 1 value (select for editing will be or yes or no) will give a value or no value, depend on the value(s) you put in the valuelist linked to the checkbox.

Searching for this value is basically not searching for a 'checked value', but for a value in the field.

So, if editing = 1, you make a search script, something along these lines:

Go to layout(your layout)
Enter find Mode ()
Set field, your field (checkboxfield) 1
Perform find
Go to layout (your layout)

Here you dont't need a 'special search' layout, it's all scripted for 1 single purpose.

Because the not checked records will have no values you make the same script with 1 additional step to find the not '1' records.

Just add
Show omitted only after the perform find step to find the records.
 
Ok i think i get how you link it.

So my field is named select record for editing.
and in the value list of the check box set i made it "edit this record".

So would the if statement look like

if(select record for editing = edit this record)
omit record
end if




i would have a loop going through all the records
to see which ones have the valule "edit this record" if it was checked.
(i am having trouble writing the script where you loop through all records, i cant seem to get passed the second record, is there like a count or some variable taht i can keep track of for an if statement so the loop will look like
Loop
If(on first record)
go to record(first);
end if
If(select for editing = edit this record)
omit record
end if
go to record(next)
exit loop if(get(record number) > get (total number records);

im not sure if this is the correct way to do it.


then i would run a script after that going into another layout then find mode which will then only show the omitted records.

thank you
 
im seriously confused with the script;

i think i may be doing something wrong with the way you suggested it.

i made a dummy database to try the algorithm and it looks like this.

i have a field that is just a number which i can keep track of the record im on.

then a text field that is labeled select for editing with the filed format as a checkbox field.

the checkbox field's value list only has one value that is
Edit this record.

from this i wrote the script

Go to layout(my layout)
Enter Find Mode ()
Set Field[Untitled:: select for editing = "Edit this record"]
Perform Find/replace

go to layout [my layout].

 
Sorry actually my script looks like

Go To layout(myLayout)
Enter Find Mode()
Set Field[myLayout::Select for editing]
Perform Find/Replace
go to layout [myLayout]

fist i tried the perform find/replace with no definitons

currently i have it specified To perform : find next

and in the find wha:
myLayout::select for editing = "Edit this record"

with matching whole words and searching through all records.

also i realized that the script actually asks the user to input some criteria as well as click the find button to continue the find.

I want it all automated. im just currently having a lot of difficulty setting this script up.

if im correct the script is to direct me to the layout i choose enters find mode in that layout and then goes into
the selected fied (in this case select for editing is my field) then performs a find on records that have the value Edit this record for my select record for editing field.

which is given if the checkbox is checked.

thank you again
 
I think we are talking about 2 different things here, or maybe 3.

What do want to achieve ?

Marking record to edit,
find records that are marked as to edit.

Then what is your criteria for a marked record ?
 
Ok first i want to find records that are marked as to edit,
which i believe you gave me a suggestion

Go to layout(your layout)
Enter find Mode ()
Set field, your field (checkboxfield) 1
Perform find
Go to layout (your layout)

however i may have done something incorrectly,

after the records are found i want to switch it to a layout that will be view only from that layout the user can click a button taht will allow them to edit the found records
 
First you have to 'mark' the needed records.
You can use a script for that, after you have the criteria for a marked record.

I don't fully understand;'i want to switch it to a layout that will be view only from that layout the user can click a button taht will allow them to edit the found records'

Are those records locked that you want to switch to a layout where they can 'edit'records ?
 
what i meant is that after the found set the user will be in a layout where the fields can not be entered, if they want to enter the fields they must press the edit found records button
which i have working
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top