title: What is the proper way to fill a form with multiple data fields?
body: <p>I have been asked to create a vb.net WinForms app that automates the creation of this spreadsheet:</p>
  
  <p><a href="https://i.stack.imgur.com/SVutW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SVutW.png" alt="enter image description here"></a></p>
  
  <p>Obviously, creating that spreadsheet manually is a back breaking task.</p>
  
  <p>I am very comfortable writing SQL to pull each individual field of data, however I've got to believe that there is a better way.  Such a method would require 144 queries !!</p>
  
  <p>I've considered creating a form with individual labels for each field, or using a gridview.  Either would be acceptable to the end user, but I'm really not sure how I would write a query to produce a dataset that look like the end product anyway.</p>
  
  <p>I'm not asking anyone to write any code for me, what I'm asking for help with is the concept of how I should attack this task.</p>
  
  <p>Here is a query that I wrote which returns the fields for Business Unit #1 for the first week on the spreadsheet.  I don't think it helps much, but I'm adding it to show that I've put some effort into this.</p>
  
  <pre><code>DECLARE @WeekEnding AS DATE
  DECLARE @DIV AS INT
  
  SET @WeekEnding = '11/13/2015'
  SET @DIV = 20
  
  -- A/R downpayments OPCH
  SELECT 
  SUM(OPCH.DocTotal - OPCH.VatSum - OPCH.TotalExpns) AS 'ARDownPaymentInvoice'  
  
  FROM OPCH 
  LEFT JOIN INV1 ON OPCH.DocEntry = INV1.DocEntry AND INV1.VisOrder = 0
  LEFT JOIN OITM ON INV1.ItemCode = OITM.ItemCode 
  LEFT JOIN OITB ON OITM.ItmsGrpCod = OITB.ItmsGrpCod 
  LEFT JOIN OACT AS CurrCode (NOLOCK) ON OITB.RevenuesAc = CurrCode.AcctCode 
  
  WHERE DATEPART(WEEK, OPCH.DocDate) = DATEPART(WEEK, @WeekEnding) AND YEAR(OPCH.DocDate) = YEAR(@WeekEnding)
  AND CurrCode.Segment_4 = @DIV
  
  
  -- Credits ORIN 
  SELECT 
  SUM(ORIN.DocTotal - ORIN.VatSum - ORIN.TotalExpns) * -1 AS 'Credit'  
  
  FROM ORIN 
  LEFT JOIN INV1 ON ORIN.DocEntry = INV1.DocEntry AND INV1.VisOrder = 0
  LEFT JOIN OITM ON INV1.ItemCode = OITM.ItemCode 
  LEFT JOIN OITB ON OITM.ItmsGrpCod = OITB.ItmsGrpCod 
  LEFT JOIN OACT AS CurrCode (NOLOCK) ON OITB.RevenuesAc = CurrCode.AcctCode 
  
  WHERE DATEPART(WEEK, ORIN.DocDate) = DATEPART(WEEK, @WeekEnding) AND YEAR(ORIN.DocDate) = YEAR(@WeekEnding)
  AND CurrCode.Segment_4 = @DIV
  
  --Invoices
  SELECT 
  SUM(OINV.DocTotal - OINV.VatSum - OINV.TotalExpns) AS 'Invoice'  
  
  FROM OINV 
  LEFT JOIN INV1 ON OINV.DocEntry = INV1.DocEntry AND INV1.VisOrder = 0
  LEFT JOIN OITM ON INV1.ItemCode = OITM.ItemCode 
  LEFT JOIN OITB ON OITM.ItmsGrpCod = OITB.ItmsGrpCod 
  LEFT JOIN OACT AS CurrCode (NOLOCK) ON OITB.RevenuesAc = CurrCode.AcctCode 
  
  WHERE DATEPART(WEEK, OINV.DocDate) = DATEPART(WEEK, @WeekEnding) AND YEAR(OINV.DocDate) = YEAR(@WeekEnding)
  AND CurrCode.Segment_4 = @DIV`
  </code></pre>
  
  <p>Thanks for any ideas.</p>