2 years ago

#64578

test-img

Seyyed

MS Access datasheet no output from Pass-Through query

I Created a datasheet form (frmSales) in MS-Access Pro Plus 2021 based on a Crosstab query (qrySales) jus for report. The "qrySales" itself reads data from a linked view (dbo_Sales) from a back-end which is SQL Server 2019. Everything is fine and the result is what I expected.

As I don't want to deal with back-end too much and there is no need to update the data, I created a Pass-Through query (PTSales) copying the same SQL codes from SQL view. The query (qrySales) now reads data from Pass-Through (PTSales). The output of Crosstab query (qrySales) is the same as before and fine, but the problem is that my datasheet form (frmSales) shows nothing now. I played with Recordset type, Data Entry and Allow Additions in datasheet form but get no result. Here is the code used in view (dbo_Sales) and Pass-Through query (PTSales).

SELECT
  c.CompanyName AS Customer
 ,p.TotalOfItem AS Sales
 ,q.ExchangeRate AS ExRate
 ,q.LastStatus AS Status
 ,q.IsProject AS Type
 ,q.INVDate AS [Invoice Date]
FROM dbo.tblProducts p
INNER JOIN dbo.tblQuotations q
  ON p.QuotationID = q.QuotationID
INNER JOIN dbo.tblCompany c
  ON q.CompanyID = c.CompanyID
WHERE q.RevActivated = 1
AND q.StatusCode IN (10, 11)

and here is the Crosstab query:

TRANSFORM Sum(IIf(DoExRate(),[Sales]*[ExRate],[Sales])) AS Sum1
SELECT
    PTSales.Customer
  , Sum(IIf(DoExRate(),[Sales]*[ExRate],[Sales])) AS [Sum]
FROM
    PTSales
WHERE
    (
        (
            (
                PTSales.[Invoice Date]
            )
            Between [Forms]![frmReportsMenu]![FromDate] And [Forms]![frmReportsMenu]![ToDate]
        )
        AND
        (
            (
                PTSales.Type
            )
            ALike IIf(IsProjectRun()=0,"%",IsProjectRun())
        )
    )
GROUP BY
    PTSales.Customer PIVOT PTSales.Status In ("Invoiced","Paid");

What is the problem here?

sql-server

ms-access

crosstab

pass-through

datasheet

0 Answers

Your Answer

Accepted video resources