vb访问窗体未显示查询的所有记录

yks3o0rb  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(274)


我有一个返回98条记录的查询,但当我试图将其替换为窗体的记录源时,它返回92或94条记录,有时它会显示98条记录。我不知道是什么问题。

SELECT ts1.Id, ts1.Narration, ts1.Mode, ts1.ChequeNo, ts1.Dated, 
       tcs.CustomerID, tcs.Name, ts1.Debit, ts1.Credit, 
       (IIf((select Sum([Debit])-Sum([Credit]) from tblTransactions 
             where cDate(Dated) < cDate(ts1.Dated) and AccountId='1010592'
               and IsDeleted=false) Is Null,
              0,
             (select Sum([ts.Debit])-Sum([ts.Credit]) from tblTransactions ts
              where cDate(ts.Dated) < cDate(ts1.Dated) and ts.AccountId='1010592'
              and ts.IsDeleted=false )) + 
        IIf((select Sum([ts2.Debit])-Sum([ts2.Credit]) from tblTransactions ts2 
             where cDate(ts2.Dated) = cDate(ts1.Dated) and ts2.Id<ts1.Id  
               and ts2.AccountId='1010592' and ts2.IsDeleted=false ) Is Null, 
             0, 
            (select Sum([ts3.Debit])-Sum([ts3.Credit]) from tblTransactions ts3 
             where cDate(ts3.Dated) = cDate(ts1.Dated) and ts3.Id<ts1.Id 
               and ts3.AccountId='1010592' and ts3.IsDeleted=false )) +
            ts1.Debit - ts1.Credit) AS Balance 
FROM tblTransactions AS ts1 
INNER JOIN tblCustomers AS tcs ON ts1.AccountId = tcs.CustomerID 
WHERE tcs.CustomerID = '1010592' 
  AND cDate(Dated) between cdate('01-Mar-20') AND cdate('20-Jun-20') 
  AND ts1.IsDeleted = false  
ORDER BY cDate(Dated) asc, Id asc
vaqhlq81

vaqhlq811#

假设sql语法没有问题,只需添加 Requery 因为仅仅改变表单记录源中的sql是不够的。您必须实际重新运行查询调整。

Me.Form.RecordSource = ledgerqry
Me.Form.Requery

相关问题