Fetching data in header and line table based on text box

smshydsmshyd Member Posts: 72
Hi,
Can any body give me idea on this. I have form based on the tables similar to sales header and sales line which contains data in it. But the requirement is that , when we open form, we should not able to see any records in it. User will be given one text box in which users enters the primary key of that table then data from both in header and line should be fetched. can any body give me idea how to achieve this

Comments

  • vijay_gvijay_g Member Posts: 884
    Why you want to do this and what you have tried as of now?
  • gerrykistlergerrykistler Member Posts: 149
    Look at the General Journal form as a place to start. Where the Batch Name is you could set this to blank or some value which will never exist each time the form is opened. Then this would be where the user enters or even looks up the record they want to display.
    Gerry Kistler
    KCP Consultores
  • smshydsmshyd Member Posts: 72
    this code in general journal is not working in the above forms

    GenJnlLine.FILTERGROUP := 2;
    GenJnlLine.SETRANGE("Journal Batch Name",CurrentJnlBatchName);
    GenJnlLine.FILTERGROUP := 0;

    can any body suggest how to block showing of all records when form is opened or until that primary key is specified
  • SavatageSavatage Member Posts: 7,142
    We have a form that has 1 textbox where an PO# is entered (scanned into)

    It searchs the sales orders and if it finds a match it bings up that order.
    If it doesn't find a match it then searches the posted invoices.
    If it finds a match it then brings up that invoice.
    else it says order not found.

    We call it our quick search form.
    Sounds like you are looking for something like that. or you can study the code to see how it works and then implement your own.

    InvCount->Integer
    SalesInvoiceHeader->Record->Sales Invoice Header
    SalesHeader->Record->SalesHeader
    ScanOrderNo->Code20
    SalesForm->Form->Sales Order
    InvoiceForm->Form->Posted Sales Invoice
    SourceExp of textbox = ScanOrderNo
    OnAfterValidate() of the textbox
    IF ScanOrderNo = ''
    THEN BEGIN
     MESSAGE('You Cannot Search A Blank Number!');
    END ELSE BEGIN
     SalesHeader.SETCURRENTKEY("Document Type","No.");
     SalesHeader.SETRANGE("External Document No.",ScanOrderNo);
    IF SalesHeader.FIND('-') THEN REPEAT
      InvCount := InvCount +1;
     UNTIL SalesHeader.NEXT = 0;
    IF SalesHeader.FIND('+')  THEN BEGIN
      MESSAGE('Number Of Open Order(s) Found= %1',InvCount);
      CLEAR(SalesForm);        
      SalesForm.LOOKUPMODE(TRUE);
      SalesForm.SETTABLEVIEW(SalesHeader);
      SalesForm.RUNMODAL;
      CLEAR(ScanOrderNo);
    END ELSE BEGIN
     SalesInvoiceHeader.SETCURRENTKEY("Sell-to Customer No.","External Document No.");
     SalesInvoiceHeader.SETRANGE("External Document No.",ScanOrderNo);
    IF SalesInvoiceHeader.FIND('-') THEN REPEAT
      InvCount := InvCount +1;
     UNTIL SalesInvoiceHeader.NEXT = 0;
    IF SalesInvoiceHeader.FIND('+') THEN BEGIN
      MESSAGE('Number Of Posted Order(s) Found= %1',InvCount);
      CLEAR(InvoiceForm);
      InvoiceForm.LOOKUPMODE(TRUE);
      InvoiceForm.SETTABLEVIEW(SalesInvoiceHeader);
      InvoiceForm.RUNMODAL;
      CLEAR(ScanOrderNo);
    END ELSE BEGIN
     MESSAGE('Order Not Found');
     CLEAR(ScanOrderNo);
     CurrForm.UPDATE;
    END;
    END;
    END;
    CLEAR(InvCount);
    
  • smshydsmshyd Member Posts: 72
    Can't we do in one form, above code requires two forms
  • SavatageSavatage Member Posts: 7,142
    It's one form with 1 textbox - then if calls already existing forms to pull the order you are looking for.

    now that's just an example - I don't know the exact requirement you are trying solve.

    I happen to put the textbox on a seperate form but you can try it anywhere you like.
    All the code is OnAfterValidate of the textbox so it's all inclosed in one thing.

    We use it to search posted & non posted orders - you might not need this - so you can use snipits if you like - it was just an example.
Sign In or Register to comment.