我有一个查询和一个表。表的名称是 OrderT,而查询的名称是 SearchQ。查询在那里,所以我可以让一个子表单在表单上显示搜索结果。尽管如果我的查询缺少任何字段中的任何数据,我的查询将不会在表格上显示一行。例如,如果我有字段 CustomerName、OrderNumber 和 OrderDueDate,我填写了 CustomerName、OrderNumber 但将 OrderDueDate 留空;查询不会显示它存在,因此搜索无法获取它。
即使未填写某些字段,我如何使查询显示表上的所有内容?
查询SQL:
SELECT OrderT.CustomerName, OrderT.OrderName, OrderT.OrderDesc, OrderT.DateOfPurchase, OrderT.ProjectDueDate, OrderT.EngineerDueDate, OrderT.ProjectComplete, OrderT.CutplanDueDate, OrderT.MaterialSpecs, OrderT.CutplanCode, OrderT.HardwareSpecs, OrderT.HardwareDueDate, OrderT.HardwareComplete, OrderT.PurchaseOrder, OrderT.PurchaseSupplier
FROM OrderT
WHERE (((OrderT.CustomerName) Like "*" & [Forms]![SearchF]![CustomerName] & "*") AND ((OrderT.OrderName) Like "*" & [Forms]![SearchF]![OrderName] & "*") AND ((OrderT.OrderDesc) Like "*" & [Forms]![SearchF]![OrderDesc] & "*") AND ((OrderT.DateOfPurchase) Like "*" & [Forms]![SearchF]![DateOfPurchase] & "*") AND ((OrderT.ProjectDueDate) Like "*" & [Forms]![SearchF]![ProjectDueDate] & "*") AND ((OrderT.EngineerDueDate) Like "*" & [Forms]![SearchF]![EngineerDueDate] & "*") AND ((OrderT.ProjectComplete) Like "*" & [Forms]![SearchF]![ProjectComplete] & "*") AND ((OrderT.CutplanDueDate) Like "*" & [Forms]![SearchF]![CutplanDueDate] & "*") AND ((OrderT.MaterialSpecs) Like "*" & [Forms]![SearchF]![MaterialSpecs] & "*") AND ((OrderT.CutplanCode) Like "*" & [Forms]![SearchF]![CutplanCode] & "*") AND ((OrderT.HardwareSpecs) Like "*" & [Forms]![SearchF]![HardwareSpecs] & "*") AND ((OrderT.HardwareDueDate) Like "*" & [Forms]![SearchF]![HardwareDueDate] & "*") AND ((OrderT.HardwareComplete) Like "*" & [Forms]![SearchF]![HardwareComplete] & "*") AND ((OrderT.PurchaseOrder) Like "*" & [Forms]![SearchF]![PurchaseOrder] & "*") AND ((OrderT.PurchaseSupplier) Like "*" & [Forms]![SearchF]![PurchaseSupplier] & "*"));