ms访问表单vba可见最后x条记录

时间:2018-04-12 17:38:17

标签: vba ms-access

是否可以以连续的形式添加按钮并隐藏除最后20条记录之外的所有记录?

首选NewDate。

SELECT TypeID,
   tblID.CodeID,
   APrice AS 1,
   Null AS 2,
   ADate AS NewDate
FROM tblA 
       LEFT OUTER JOIN tblID 
       ON tblID.TypeID = tblA.TypeID

UNION ALL

SELECT TypeID,
   tblID.CodeID,
   NULL AS 1,
   MPrice AS 2,
   MDate AS NewDate
FROM tblM
       LEFT OUTER JOIN tblID 
       ON tblID.TypeID = tblM.TypeID

ORDER BY NewDate;

使用TOP是一种解决方案。

1 个答案:

答案 0 :(得分:1)

如果您的表格是订单,而您只想查看字段:
订单ID,员工ID,客户ID,订单日期

您可以按降序排序ID并询问热门(x)记录。

SELECT  TOP 10 [Order ID], [Employee ID], [Customer ID], [Order Date] FROM Orders ORDER BY [Order ID] DESC;

一旦您选择了所需的记录,您就可以按日期对记录进行排序。

Private Sub Form_Load()
   Me.OrderBy = "Order Date DESC"         ' Sort by descending date.
   Me.OrderByOn = True                    ' Apply the sort order.
End Sub