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

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


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

  1. SELECT ts1.Id, ts1.Narration, ts1.Mode, ts1.ChequeNo, ts1.Dated,
  2. tcs.CustomerID, tcs.Name, ts1.Debit, ts1.Credit,
  3. (IIf((select Sum([Debit])-Sum([Credit]) from tblTransactions
  4. where cDate(Dated) < cDate(ts1.Dated) and AccountId='1010592'
  5. and IsDeleted=false) Is Null,
  6. 0,
  7. (select Sum([ts.Debit])-Sum([ts.Credit]) from tblTransactions ts
  8. where cDate(ts.Dated) < cDate(ts1.Dated) and ts.AccountId='1010592'
  9. and ts.IsDeleted=false )) +
  10. IIf((select Sum([ts2.Debit])-Sum([ts2.Credit]) from tblTransactions ts2
  11. where cDate(ts2.Dated) = cDate(ts1.Dated) and ts2.Id<ts1.Id
  12. and ts2.AccountId='1010592' and ts2.IsDeleted=false ) Is Null,
  13. 0,
  14. (select Sum([ts3.Debit])-Sum([ts3.Credit]) from tblTransactions ts3
  15. where cDate(ts3.Dated) = cDate(ts1.Dated) and ts3.Id<ts1.Id
  16. and ts3.AccountId='1010592' and ts3.IsDeleted=false )) +
  17. ts1.Debit - ts1.Credit) AS Balance
  18. FROM tblTransactions AS ts1
  19. INNER JOIN tblCustomers AS tcs ON ts1.AccountId = tcs.CustomerID
  20. WHERE tcs.CustomerID = '1010592'
  21. AND cDate(Dated) between cdate('01-Mar-20') AND cdate('20-Jun-20')
  22. AND ts1.IsDeleted = false
  23. ORDER BY cDate(Dated) asc, Id asc
vaqhlq81

vaqhlq811#

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

  1. Me.Form.RecordSource = ledgerqry
  2. Me.Form.Requery

相关问题