Dynamics NAV: Invoice sales form

I created a form using the sales invoice header and sales invoice line added 3 fields in main form i.e, customer no, from date and to date,and in sub form i taken the fields like item no,line no,document no,customer no, purchase date and to date. Now my task is to display the sales of an customer during the from date and to date…please say me how to filter the sales…

I think the approach is not correct -
The Header part should not be related to a table, all the fields that you need should be variables once user put values in that then lets say user clicks a button show details.
Once user click on that you filter Sales invoice line with the filter and display them to user.

can you explain me how I should create a form and where should I write code to display them to user after filtering…

I have to create a form using sales invoice line table,but there are three fields customer no, from date, to date and the fields from that table are below. but condition is when i put data in above three fields i mean customer no, from date and to date then all fields should retrieve automatically.I added a new field name purchase date and expiry date. so suggest me which type of form should i create and how, if any code need to write then please explain me?

Can you explain what is purpose of this form ? How you are going to use it ?
Are you going to display data in the subform based on the filter from main form ?

Like [mention:e7571d43b490427d9a2de58408400520:e9ed411860ed4f2ba0265705b8793d05] then I’m not quite sure what the purpose of this form is.

But generally you should never create a “sales statistics” of any kind based upon the posted sales invoice headers/lines in Navision. There are several reasons for this:

  1. In Navision the users can delete the posted sales invoice header/line tables (and the other posted documents), if it already have been posted. The reason behind this for many users surprising fact, is that all the content for the invoice is already registered in the actual ledger tables, which can never be deleted. Ex. cust. ledger entries, item ledger/value entries etc.
  2. Unless you also include the sales credit memo header/line tables, then your statistics will not show the correct amounts, when you compare to the other sales statistics in NAV. You have to deduct the credit memo quantities/amounts.

So a form to display the purchase by a specific customer within a given period is ideally made using the value entry table. You can then filter on customer number and posting date.
See report no. 113 (customer/item sales report).