O
Oscar
This is the actual query :
recordset rstA:
"SELECT cancelled FROM tblOrders WHERE ID_company=" & ID_comp & " ORDER BY
ID DESC"
IF NOT rstA.eof THEN
IF rstA!cancelled=FALSE then
(process something)
ENDIF
ENDIF
This works fine, however I want to optimize the query by adding the
verification of column cancelled within the original query so that I only
need to verify if the recordset holds a record. I want to know how I can
build the query which first finds the latest added order of a company and
verifies if the order has been cancelled by verifying the value of column
'cancelled'. In case I use WHERE cancelled=0 :
"SELECT cancelled FROM tblOrders WHERE ID_company=" & ID_comp & " AND
cancelled=0 ORDER BY ID DESC"
it selects the records with column cancelled set to false first which
doesn't need to be the latest within the table.
So my question is : how can I implement this verification into one query
such that it results only one record when the latest order has not been
cancelled and no rows otherwise?
recordset rstA:
"SELECT cancelled FROM tblOrders WHERE ID_company=" & ID_comp & " ORDER BY
ID DESC"
IF NOT rstA.eof THEN
IF rstA!cancelled=FALSE then
(process something)
ENDIF
ENDIF
This works fine, however I want to optimize the query by adding the
verification of column cancelled within the original query so that I only
need to verify if the recordset holds a record. I want to know how I can
build the query which first finds the latest added order of a company and
verifies if the order has been cancelled by verifying the value of column
'cancelled'. In case I use WHERE cancelled=0 :
"SELECT cancelled FROM tblOrders WHERE ID_company=" & ID_comp & " AND
cancelled=0 ORDER BY ID DESC"
it selects the records with column cancelled set to false first which
doesn't need to be the latest within the table.
So my question is : how can I implement this verification into one query
such that it results only one record when the latest order has not been
cancelled and no rows otherwise?