S
Steven Sutton
The problem I am having is with an SQL statement I wrote in VBA but the
examples I am giving actually come from a Query where I could let Access
write the SQL statement for me.
I have a table that has 1143 records in it. If I run the following Query it
returns 11 records, which is correct:
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, tblJobs.txtJobName,
tblJobs.Status, tblJobs.dtEntered, tblJobs.dtModified, tblJobs.txtUsername,
tblJobs.intStatusSort
FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID =
tblJobs.intJobID
WHERE ((tblJobs.Status)<>'Completed');
If I run this Query, it returns 1142 records - also correct (at this time,
there is only one record with the Status of 'Canceled':
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, tblJobs.txtJobName,
tblJobs.Status, tblJobs.dtEntered, tblJobs.dtModified, tblJobs.txtUsername,
tblJobs.intStatusSort
FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID =
tblJobs.intJobID
WHERE ((tblJobs.Status)<>'Canceled');
But if I run this Query, I get all 1143 records and it seems to me that I
should be getting 10 - the 11 that aren't 'Completed' minus the one that is
'Canceled':
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, tblJobs.txtJobName,
tblJobs.Status, tblJobs.dtEntered, tblJobs.dtModified, tblJobs.txtUsername,
tblJobs.intStatusSort
FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID =
tblJobs.intJobID
WHERE (((tblJobs.Status)<>'Canceled')) OR (((tblJobs.Status)<>'Completed'));
Does anyone see why I am not getting the results I am expecting? If I
haven't made it clear, what I am wanting is to exclude all records whose
Status is either 'Completed' or 'Canceled' but instead I am getting all
records. Any suggestions? Thanks again to all who help.
examples I am giving actually come from a Query where I could let Access
write the SQL statement for me.
I have a table that has 1143 records in it. If I run the following Query it
returns 11 records, which is correct:
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, tblJobs.txtJobName,
tblJobs.Status, tblJobs.dtEntered, tblJobs.dtModified, tblJobs.txtUsername,
tblJobs.intStatusSort
FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID =
tblJobs.intJobID
WHERE ((tblJobs.Status)<>'Completed');
If I run this Query, it returns 1142 records - also correct (at this time,
there is only one record with the Status of 'Canceled':
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, tblJobs.txtJobName,
tblJobs.Status, tblJobs.dtEntered, tblJobs.dtModified, tblJobs.txtUsername,
tblJobs.intStatusSort
FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID =
tblJobs.intJobID
WHERE ((tblJobs.Status)<>'Canceled');
But if I run this Query, I get all 1143 records and it seems to me that I
should be getting 10 - the 11 that aren't 'Completed' minus the one that is
'Canceled':
SELECT tblJobTickets.JobNumber, tblJobs.intJobID, tblJobs.txtJobName,
tblJobs.Status, tblJobs.dtEntered, tblJobs.dtModified, tblJobs.txtUsername,
tblJobs.intStatusSort
FROM tblJobTickets RIGHT JOIN tblJobs ON tblJobTickets.intJobID =
tblJobs.intJobID
WHERE (((tblJobs.Status)<>'Canceled')) OR (((tblJobs.Status)<>'Completed'));
Does anyone see why I am not getting the results I am expecting? If I
haven't made it clear, what I am wanting is to exclude all records whose
Status is either 'Completed' or 'Canceled' but instead I am getting all
records. Any suggestions? Thanks again to all who help.