Form & Filter

Hi All, i’ve tried the following code: Mat:Form Header:Table CLEAR(Mat); Mat.function(FALSE); //Necessary Functioncall IF Mat.RUNMODAL = ACTION::LookupOK THEN BEGIN Mat.GETRECORD(Header); FORM.RUNMODAL(74026, Header); END; I call a form with sourcerec Header. The User can serch for a certain rec by setting special Filters. After closing the form a second form (with sourcerec header and subform)with the selected record is called. Everything works fine, but in want the filters the user sets in the first form to stay alive in the second form. What is my mistake? Thanks in advance Greetings, Frank

There is a few tricks to do this. 1. The form that needs the filter from the other form needs to be created as a variable. 2. In that same form create a function called Set Filters. In that function create parameter for the filter that is begin set. In that function you need only a single line of code like: CopyFilters(FilterRecAsParam); 3. In the first form, on the OnCloseForm event, call the function in the second form. 4. Next (if LookupOK) then Form.Runmodal. This is the method I always use in cases similar to yours. Hope this helps. Feel free to e-mail me if you have any more questions. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117

Hi William, thanks a lot for your answer. I’ve tried it, but it doesn’t work. I have created a function in the second form with the following code Copyfilters() I call this function in the oncloseForm-event of the first form. After that i have tried the following: if Mat.runmodal = Action::LookUpOK then begin Mat.GETRECORD(Header); FORM.RUNMODAL(74026, Header); end; I put a second line in function setfilters: IF HASFILTER(Rec) THEN MESSAGE(‘Filter’); When the Function setfilters is called, rec of the second form contains filters (MESSAGE is displayed), but when the form is opened, all filters are gone! Is this a problem of the Version of NF? I had to work with 2.0 Greetings, Frank

Note sure why it isn’t working for you. You can send me the objects if you wish & I’ll take a look at it for you. You would need to send tables, forms, everything it references. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117 Edited by - wbenefiel on 2001 Jul 03 17:37:04

Try this:


CLEAR(Mat);
Mat.function(FALSE); //Necessary Functioncall
IF Mat.RUNMODAL = ACTION::LookupOK THEN
BEGIN
 Mat.GETRECORD(Header);
 Mat.MyCopyfilters(Header);
 FORM.RUNMODAL(74026, Header);
END;

... in Mat form ...
MyCopyfilters (Var Header:table) // Var is necessary !!!
Header.COPYFILTERS(Rec);

 

Hi, SETTABLEVIEW should do the trick. You will have to define the form 74026 as variable: Var Form74026: Form 74026; IF … LookupOK THEN BEGIN Clear(Form74026); Form74026.SETTABLEVIEW(Header); Form74026.RUNMODAL; END;

First thanks to all answers, and your offer William. I’ve tried it with dalius` solution and all filters set with setrange and setfilters are copied. My problem is that in some situations an additonal filter is set with mark(true) and markedonly(true). This filter is not copied. Does copyfilters not copy a filter set by mark and markedonly? Or is there another fine Trick? Thanks in advance Greetings, Frank

You can’t copy marks, but you can do following change in MyCopyfilters:


MARKEDONLY(TRUE);
IF FIND('-') THEN 
REPEAT
  Header.GET(Rec.......);
  Header.MARK(TRUE);
UNTIL NEXT=0;

 

Is there any reason why you don’t call Form 74026 from within Form Mat? (Just an idea) ------- With best regards from Switzerland Marcus Fabian