skip records on form

I have a question. When I am on the SalesInvoice Card, I would like to show only records with the following condition: Show only when: SalesInvoiceHeader.SalesPersonCode = USERID or SellToCustomer.SalesPersonCode = USERID. All the other records has to be skipped and not being displayed on screen. Is there a proper way to do that?

You could do this with the MARK-function, e.g.:

  IF (SalesInvoiceHeader.SalesPersonCode = USERID) THEN
  SellToCustomer.GET(SalesInvoiceHeader."Sell To Customer No.");
  IF (SellToCustomer.SalesPersonCode = USERID) THEN
UNTIL SalesInvoiceHeader.NEXT = 0;

This - or something similar - should do it … Regards, Jörg

Why not just use a regular filter? on OpenForm do: SetFilterGroup(9); setrange(“Salesperson Code”,USERID"); SetFilterGroup(0); The Filter group is so that no “clever user” does a Show All and shows all of them Also if you were doing this on unposted docs where the user is creating new ones then also on OnNewRecord: “salesperson code” := userid; Otherwise he will insert new recs and then they will dissapear since they do not match the filter Hope that works. Regards Cristi Nicola


Originally posted by cnicola
Why not just use a regular filter?

Because the filter condition is an OR-condition on two fields (SalesInvoiceHeader.SalesPersonCode = USERID ORSellToCustomer.SalesPersonCode = USERID), which is a little difficult to do with regular filters… [8D]

Hi xorph, I am sorry I did not read it properly [:I] But really is Roelof’s fault. If he made the “or” bolded I would have seen it [;)] Cristi

Thank you all. I figured it out and it works the way you describe it. Only thing what has my concerns is the fact that I can’t use filtergroups this way. It means that ‘clever’ users are still be able to find all the records and not only the ones with the filter. Because ‘show all’ will remove the filter settings. Appearently I used the code the way Cristi showed. Only in this way ‘show all’ has no effect. Any suggestions? Thanks, Roelof.

If you have Attain you can use Responsibility Centers for this. It’s a standard feature.

Hi, it’s only a (not so proper) hint: Put the filter code in the OnAfterRecord- trigger. So the user can choose ‘Show All’ but if he changes the record the filter will work again. bye Andre