Problem with a code

DarkHorseDarkHorse Member Posts: 389
Hello, I've the following code in a report:

IF ("Field1" <> '') THEN
BEGIN
table1.INIT;
var1:="Field1";
table1.SETFILTER("Document No.",var1);
table1.FIND('-');
END;

I want that the report shows me the Document No. equal to the Field1 from the all table1, but it don't shows me the correct Document No. What's the problem of the code?
Thanks in advance.

Comments

  • Igor_BeeoneIgor_Beeone Member Posts: 80
    Hello,
    if ("Field1"<>'') then
    begin
      var1:="Field1";
      table1.reset;
      table1.setrange("Document No.",var1);
      if table1.find('-') then
      begin
        //add code here
      end;
    end;
    
    Hope it helps.
    Br,
    Igor Beeone
  • DarkHorseDarkHorse Member Posts: 389
    Thanks for your help, but it shows me the same Document No. It's strange because the rest of the fields it shows me right, but not the document number that repeats along the report. Any other idea please?.
    Thnaks for your help.
  • bbrownbbrown Member Posts: 3,268
    Why not simply...


    table1.RESET;
    table1.SETFILTER("Document No.",Field1);
    IF table1.FIND('-') THEN BEGIN
    ..more code here...
    END;
    There are no bugs - only undocumented features.
  • Igor_BeeoneIgor_Beeone Member Posts: 80
    Could you please describe the situation you want to implement :)
  • DarkHorseDarkHorse Member Posts: 389
    Thanks everybody for help. I'll try every options but it doesn't run. I describe the situation.
    The report shows movements of invoices. In each registry there is a field (Field1) that has an invoice number (Document No.) that already exist and corresponds as well to a invoice number.
    I want that, when the report find a registry which has the Field1 informed, the report find the number of invoice (Document No.) which has that number and show them, because there are two or more invoices with the same numeration. The code that I have put before show me an invoice number that doesn't is equal to the Field1, but takes corretly the registers asociateds to the correct numbre; it's strange.
    Sorry if I don't explained well myself. Any idea?
  • DarkHorseDarkHorse Member Posts: 389
    Hello again, I've get that the report shows me the correct document number, this is the code:

    IF ("Field1" <> '') THEN
    CurrReport.SHOWOUTPUT(TRUE)
    ELSE CurrReport.SHOWOUTPUT(FALSE);
    IF ("Field1" <> '') THEN
    BEGIN
    varl1:="Field1";
    table1.SETFILTER("Document No.",varl1);
    table1.FIND('-');
    END;

    But the only probem is that it shows me only one document number, and, in more cases there are more documents with the same numbre. Any idea please?.
    Thanks.
  • Igor_BeeoneIgor_Beeone Member Posts: 80
    Hello,
    as I understood:
    1) If you need just manipulating within code:
    IF ("Field1" <> '') THEN 
    CurrReport.SHOWOUTPUT(TRUE) 
    ELSE CurrReport.SHOWOUTPUT(FALSE); 
    IF ("Field1" <> '') THEN 
    BEGIN 
    varl1:="Field1"; 
    table1.SETFILTER("Document No.",varl1); 
    table1.FIND('-'); //first document found with code=varl1
    repeat
    //Reads here rest of documents with same document no.
    until table1.next=0;
    END; 
    
    But it seems that maybe you would like to printout some info for every document identation. In this case make Main-Detail report:
    For example your table Sales Header is the main table and Sales Line is detail table (contains order lines):
    1) Create a report
    2) Input Main table name (Sales Header) in DataItem
    3) Input Detail table name then (next line)
    4) for Sales Line push left arrow button
    5) select Sales Line DataItem and go to it's properties
    6) Input DataItemLink property with: Document No.=FIELD(No.)

    Now you will get in sections Sales Line body where sales lines will appear for every document within Sales Header :)

    Hope it helps. Sorry if I'm missunderstanding your needs.
    Br,
    Igor Beeone
  • DarkHorseDarkHorse Member Posts: 389
    Thank you very much for your help. I'll try but it doesn't runs, I can't find the problem. I'll keep on trying to find the mistake.
    Thank you again for your help and your time.
Sign In or Register to comment.