确定某批货件是否已为当月开具账单

Determine if a shipment has been billed for the month

我有一个仓储数据库,它使用 "ShipRefs"(在表单上标记为装运)字段将项目与特定装运相关联。我现在正在创建一个发票表格,以便每月为该客户的每批货物生成账单。我可以 select 通过组合框根据客户发货,但我无法根据当月是否已开具账单来过滤这些发货。

确定当月装运是否已开具账单并仅在组合框中显示未开具账单的最佳方法是什么? (请注意 "Last Billdate" 字段是一次失败的尝试) 数据:

查询货件组合框行来源:

SELECT DISTINCT ItemList.ShipRef, ItemList.CRef, InvoiceData.[Last Billdate]
FROM ItemList AS ItemList_1, ItemList INNER JOIN InvoiceData ON ItemList.ShipRef = InvoiceData.Shipment
WHERE (((ItemList.CRef)=[Forms]![InvoiceData]![Customer]) AND ((InvoiceData.[Last Billdate])>=Date()-30));

根据您的回复...

I want only the records that do not fall within the current month and yes only records where the invoice date is null

我认为 DateSerial() 在这里应该对确定目标日期有用。这是一个即时 window 示例:

? DateSerial(Year(Date()), Month(Date()), 1)
9/1/2015 

? DateSerial(Year(Date()), Month(Date()) + 1, 1)
10/1/2015 

这是一个使用那些 DateSerial 表达式并将结果集限制为 发票日期 为空的行的查询:

SELECT id.*
FROM InvoiceData AS id
WHERE
    id.[Invoice Date] Is Null
    And
        (
               id.[Last BillDate] < DateSerial(Year(Date()), Month(Date()), 1)
            Or id.[Last BillDate] >= DateSerial(Year(Date()), Month(Date()) + 1, 1)
        );