Hello I am creating a database for work that allows me to enter maintenance tasks for computers into an access database using forms. I have one main table that holds all of the data re the tasks. Its called "Tasks" and comtains the following fields:
TaskID (primary key)
EmployeeID
Date
Window
Serial #
Problem Category
ProblemSubCategory
Severity
TaskStatus
Comments
This table is then connected to several other sub tables with a 1 to many relationship. these sub tables are: Employees, TaskStatus, Window, Severity, ProblemCategory and ProblemSubCategory.
I use a form to enter a maintenace tasks and have it setup to be able to search for tickets using the employee name (and/or) Severity (and/or) Status. The resulting SQL allows this to work:
SELECT Task.TaskID, Task.Date, Task.[Serial #], Severity.Severity, TaskStatus.TaskStatus, Employees.Employees, Task.Comments
FROM TaskStatus INNER JOIN (Severity INNER JOIN (Employees INNER JOIN Task ON Employees.EmployeeID=Task.EmployeeID) ON Severity.SeverityID=Task.Severity) ON TaskStatus.TaskStatusID=Task.TaskStatus
WHERE ((([Task.EmployeeID]=Forms!TaskAdmin!Combo59 Or forms!TaskAdmin!Combo59 Is Null)=True) And (([Task.Severity]=Forms!TaskAdmin!Combo61 Or Forms!TaskAdmin!Combo61 Is Null)=True) And (([Task.TaskStatus]=Forms!TaskAdmin!Combo71 Or Forms!TaskAdmin!Combo71 Is Null)=True));
This will accept a value from one of the combo boxes or a NULL value in which case it is ignored.
What I want to do is also add some code to the existing SQL to also allow me to search for tickets based on a start date and end date. I tried to use the following code to accomplish this :
OR Between (([Task.Date]=[Forms]![TaskAdmin]![StartDate] Or [Forms]![TaskAdmin]![StartDate] Is Null)=True)) And (([Task.Date]=[forms]![TaskAdmin]![EndDate] Or [Forms]![TaskAdmin]![EndDate] is Null)=True))
However when I attempt to save this, access reports a "syntax error(missing operator) in query expression".
I think I could solve this by making a 2nd query, but then I don't think I could use the date search with the employee search. I want to be able to search by employee (and/or) Status (and/or) Severity (and/or) Start Date and End Date.
I have looked all over the internet in various forums to find an answer here, but have come up short. I know a bit about SQL but an far from being an expert.
Anyway I hope that someone here might be able to help and would appreciate any response.
Any takers ?
TaskID (primary key)
EmployeeID
Date
Window
Serial #
Problem Category
ProblemSubCategory
Severity
TaskStatus
Comments
This table is then connected to several other sub tables with a 1 to many relationship. these sub tables are: Employees, TaskStatus, Window, Severity, ProblemCategory and ProblemSubCategory.
I use a form to enter a maintenace tasks and have it setup to be able to search for tickets using the employee name (and/or) Severity (and/or) Status. The resulting SQL allows this to work:
SELECT Task.TaskID, Task.Date, Task.[Serial #], Severity.Severity, TaskStatus.TaskStatus, Employees.Employees, Task.Comments
FROM TaskStatus INNER JOIN (Severity INNER JOIN (Employees INNER JOIN Task ON Employees.EmployeeID=Task.EmployeeID) ON Severity.SeverityID=Task.Severity) ON TaskStatus.TaskStatusID=Task.TaskStatus
WHERE ((([Task.EmployeeID]=Forms!TaskAdmin!Combo59 Or forms!TaskAdmin!Combo59 Is Null)=True) And (([Task.Severity]=Forms!TaskAdmin!Combo61 Or Forms!TaskAdmin!Combo61 Is Null)=True) And (([Task.TaskStatus]=Forms!TaskAdmin!Combo71 Or Forms!TaskAdmin!Combo71 Is Null)=True));
This will accept a value from one of the combo boxes or a NULL value in which case it is ignored.
What I want to do is also add some code to the existing SQL to also allow me to search for tickets based on a start date and end date. I tried to use the following code to accomplish this :
OR Between (([Task.Date]=[Forms]![TaskAdmin]![StartDate] Or [Forms]![TaskAdmin]![StartDate] Is Null)=True)) And (([Task.Date]=[forms]![TaskAdmin]![EndDate] Or [Forms]![TaskAdmin]![EndDate] is Null)=True))
However when I attempt to save this, access reports a "syntax error(missing operator) in query expression".
I think I could solve this by making a 2nd query, but then I don't think I could use the date search with the employee search. I want to be able to search by employee (and/or) Status (and/or) Severity (and/or) Start Date and End Date.
I have looked all over the internet in various forums to find an answer here, but have come up short. I know a bit about SQL but an far from being an expert.
Anyway I hope that someone here might be able to help and would appreciate any response.
Any takers ?