within a record I want to only show when printing 'matching fields', and omit those that don't match.
Is there a way to use "hide when printing" in a script please?
Can you post example data?
Records/field to show
Records/fields to hide
Sent from miPhone
I script to search the DB for a unique record
and then something like this ....
if(field1≠ "test1";field21="hide when printing"; if(field2≠ "test1"; field2="hide when printing"; if field3≠ test1 etc etc for 6 fields,
then I run for test2, and test3 etc etc
after each test I want to print the found record with whichever of the fields pass the test,
and then reset the fields to print if required i.e. not to be hidden after the script has run
typo correction for clarity - sorry!
if(field1≠ "test1";field1="hide when printing"; if(field2≠ "test1"; field2="hide when printing"; if field3≠ test1 etc etc for 6 fields,
Rephrasing into pseudocode to confirm if I know what you mean, because the use of the equal sign in your code is making it very confusing:
If field 1 is not "abc", hide it when printing.
If field 2 is not "xyz", hide it when printing.
//each field has a hard-coded test value. in this case "abc" is the test value for field 1, and "xyz" is the test value for field 2.
You could just put this formula in "hide object when": Self ≠ "abc"
But I have a feeling there is more to it than you're letting on. Might want to present a real world example.
You are correct Jason,
is exactly what I am trying to achieve (and thanks for you help BTW), but where can I enter "hide object when" to control the script? I've looked through the list of statements that help perform scripts, but can't find anything that allows me to change the objects visibility. There's obviously loads of things I don't know about whilst scripting!
Each of the fields I want to test have variable contents: these are fields that contain a suppliers name and goods, but each field could be any one of multiple different suppliers. I want to be able to just send each supplier the order for their goods without revealing to them what I am buying from others .... hence the need to find the unique record, but only show relevant goods to each supplier by omitting others. I hope I'm not muddying the water!
No script needed, just put the formula in "Hide Object When" under the data tab of the Inspector.
Thanks again Jason, but I don't think I've truly got my question right .... I'll have another go ....
filed1 could contain anyone of (say) 8 set answers
ditto fields 2, 3, 4, 5, 6
I want to exclude (not print) fields that don't have the same test, viz. left(field1;3), and use this test on the other 5 fields in the same record so that I get
if(left(field1;3)≠"abc"; "hide from printing" field1;
if(left(field2;3)≠"abc"; "hide from printing" field2;
if(left(field3;3)≠"abc"; "hide from printing" field3;
if(left(field4;3)≠"abc"; "hide from printing" field4;
if(left(field5;3)≠"abc"; "hide from printing" field5;
if(left(fiel6;3)≠"abc"; "hide from printing" field6; etc etc
print the record for this test,
and then start again for test2 if(left(field1;3)≠"xyz"; "hide from printing" field1; etc etc
does this help pls?
I'm being thick Jason .... I'm off to learn more on your solution; I hadn't realised I could script in "Hide Object When" under the data tab of the Inspector.
Many thanks, Michael
I also still suspect I might not fully understand your question. If you gave a real world example it might be clear.
But in terms of object hiding, it's quite simple. For each object on the layout you just need to figure out under what conditions it should be hidden, then create a formula that evaluates to true for these situations only, and put that formula in the "hide object when" for the object.
So if you want field1 to be hidden when it does not start with "abc", your formula is:
There is no scripting involved. Just click the field, go to the data tab of the inspector, add the formula to "hide object when", and you're done. The test will be evaluated for every record, and the object will be shown or hidden accordingly. Repeat for each additional layout object.
I was trying to justify the "scripting" part.
Perhaps a $$variable is used in the "Hide when..." And a script could be used to set that variable just before printing.
I would definitely also trap so manual printing can't over-step this process.
Re: "I hadn't realised I could script in "Hide Object When"…"
You are using confusing terminology here. Jason said "create a formula that evaluates to true…" which is not scripting. You don't use scripting—which is creating a routine series of actions, you use calculations—which is creating a logical formula. Such formulas can be long and complex, but they are not scripts.
Jason, Beverly and Keyword .... thanks to you all for guiding me to unblock my mind to how I get over my problem; I was too blinded by a scripting solution, and my lack of knowledge on some aspects of FM has been exposed ..... I will be more knowledgable in the coming days, when I hope I will be delighted by further skills!
All the best to you all, Michael
You might also take a step back and rethink how you have set up your tables, fields and relationships.
It it is possible that you have multiple fields where multiple related records would make for a better design.
Thanks Phil; you may well be right, and I am guilty of working with what I know and have learned, which as you will know is not necessarily the slickest way forward!
The DB does so many things, and the people who work it know what’s going on, so a change to something that would better for the DB design, wouldn’t be a step forward ….. and anyway, I’m reaching into areas I know little/ nothing about, which is fun ……
This FM community thing is great, and I can see myself dipping in and out to make myself feel very humble about what I can’t do!
All the best
Retrieving data ...