You should put all StockID values of the found set into a global text field in the Main table, as a return-separated list. Then make the relationship:
Main::gStockIDs = Stock::StockID
There are various ways to collect the IDs of the found set (some fairly complex) - I'll describe a simple one: after finding the stock items, go to a layout of Stock that contains nothing but the StockID field, and do Copy All Records. Then go to the Main layout and paste into the global field.
Many Thanks for that I never new of that feature so I can put a multitude of stock ID's in my main global file
and it will match to those stock records.
I will try it later and let you know how I get on
Once again many thanks I have been stuck on this one for about a week now
PS I am using FM10
Many Thanks That worked a treat no problem
Just to complete the picture here:
The advantage of this method is that it's very fast. On the other hand, it requires a special layout, and it destroys the user's clipboard (although this can be helped by "parking" the user's clip data in a global container).
Yes I try to keep layouts and scripts to a minimum in the interest of simplicity and future easy debugging. I have no experience of using the clip boards to any
great degree so at the moment any way, that is not a miss.
The additional layout was a small price to pay for solving the problem. I have only started testing my application in multiuser mode hopefully there will not
be many more gremlins lurking.
Once again thanks for a very efficent and concise solution.
While you don't plan to use the clipboards, your users might and they might complain that values they've copied to the clipboard have mysteriously vanished--replaced by a long list of data.
There is a variation on comment's suggestion that avoids altering the clipboard:
After finding the records....
Set Variable [$List; Value: $List & "¶" & YourTable::IDfield]
Go To Record [next; Exit after last]
Set Field [YourTable::YourGlobalTextField; Right($List; Length($list) -1)] //Right function strips off extra leading "¶"
Some have claimed that this is slightly faster than Copy All Records but I haven't tested that fact myself...
Some have claimed that this is slightly faster than Copy All Records
Who exactly made this claim where?
A previous post to this forum mentioned this. Let's see if I can find it...
OK found it. I see my memory is slightly incorrect, the post indicates that the method is slightly slower for FMP 10 and slightly faster for FMP 9.
The post refers to a test by John Mark Osborne
Thanks for that I see where you are coming from. Never thought about the clipboard in context of it being used for other applications.
I think comment posted what was the easiest solution for me to follow which it probably was.
When I have time I will test out your script
I can't believe JMO would say such nonsense.
I just did a Google search to try to find the original source:
Direct quote: "But now the Variable Loop is much faster than the global loop and Copy All Records."
See for yourself: http://www.vtc.com/products/FileMakerPro10Advanced/SaveaFoundSet/79260
Works for me. I don't rely on the performance claims of others anyway since my database design/structure/OS may differ from that of the person performing the test.
My original intent here was to point out a variation that avoids altering the contents of the clipboard.
Both versions need to be used carefully if the list of records involved is large, to avoid unecessary performance hits.