You have seen this a lot but you guys have come through time and time again for me. Here is what I am doing
I am making a query using 4 linked tables, I am using a form has start date, end date and the rest of the information is entered via combo boxes. If one combo box was left empty then I wanted to return all the data from that box.
I am not versed in SQL so I used the design view and I first started were you needed to enter all the fields in order to get a return. Then I entered "or Like[...] Is Null" to my Criteria and access populated the rest.
Code:
SELECT SellTable.Date, Equipment.Department, Equipment.PrimaryMachine, Equipment.Machine, Employee.Last, Parts.PartNo, Parts.Description
FROM Parts INNER JOIN (Equipment INNER JOIN (Employee INNER JOIN SellTable ON Employee.EmpID = SellTable.EmpID) ON Equipment.EqupID = SellTable.EqupID) ON Parts.PartID = SellTable.PartID
WHERE (((SellTable.Date) Between [Forms]![RepairSearch].[startDate] And [Forms]![RepairSearch].[endDate]) AND
((Equipment.Department)=[Forms]![RepairSearch].[cboDepartment]) AND ((Equipment.PrimaryMachine)=[Forms]![RepairSearch].[cboPrimary] Or
(Equipment.PrimaryMachine) Like [Forms]![RepairSearch].[cboPrimary]) AND ((Equipment.Machine)=[Forms]![RepairSearch].[cboMachine]) AND
((Employee.EmpID)=[Forms]![RepairSearch].[cboEmployee] Or (Employee.EmpID) Like [Forms]![RepairSearch].[cboEmployee])) OR
(((SellTable.Date) Between [Forms]![RepairSearch].[startDate] And [Forms]![RepairSearch].[endDate]) AND
((Equipment.PrimaryMachine)=[Forms]![RepairSearch].[cboPrimary] Or (Equipment.PrimaryMachine) Like [Forms]![RepairSearch].[cboPrimary]) AND
((Equipment.Machine)=[Forms]![RepairSearch].[cboMachine]) AND ((Employee.EmpID)=[Forms]![RepairSearch].[cboEmployee] Or
(Employee.EmpID) Like [Forms]![RepairSearch].[cboEmployee]) AND ((([Equipment].[Department])
Like [Forms]![RepairSearch].[cboDepartment]) Is Null)) OR (((SellTable.Date) Between [Forms]![RepairSearch].[startDate] And
[Forms]![RepairSearch].[endDate]) AND ((Equipment.Department)=[Forms]![RepairSearch].[cboDepartment]) AND
((Equipment.PrimaryMachine)=[Forms]![RepairSearch].[cboPrimary] Or (Equipment.PrimaryMachine) Like [Forms]![RepairSearch].[cboPrimary]) AND
((Employee.EmpID)=[Forms]![RepairSearch].[cboEmployee] Or (Employee.EmpID) Like [Forms]![RepairSearch].[cboEmployee]) AND
((([Equipment].[Machine]) Like [Forms]![RepairSearch].[cboMachine]) Is Null)) OR (((SellTable.Date) Between
[Forms]![RepairSearch].[startDate] And [Forms]![RepairSearch].[endDate]) AND ((Equipment.PrimaryMachine)=[Forms]![RepairSearch].[cboPrimary] Or
(Equipment.PrimaryMachine) Like [Forms]![RepairSearch].[cboPrimary]) AND ((Employee.EmpID)=[Forms]![RepairSearch].[cboEmployee] Or
(Employee.EmpID) Like [Forms]![RepairSearch].[cboEmployee]) AND ((([Equipment].[Department]) Like [Forms]![RepairSearch].[cboDepartment]) Is Null) AND
((([Equipment].[Machine]) Like [Forms]![RepairSearch].[cboMachine]) Is Null))
ORDER BY SellTable.Date;
Is there am easier way to do this.