OK all of the other listboxes work except this one which has a criteria.
SELECT tblItemTypes.ItemTypeID,tblItemTypes.ItemTypeName
FROM tblItemTypes UNION SELECT 0,"All Types" FROM tblItemTypes
WHERE tblItemTypes.ItemTypeID Not Like 5
ORDER BY ItemTypeName;
it's not excluding the one record.
Thanks
DS
What's the datatype of the ItemTypeID field? Is it a Number or Text?
If it is a Text datatype, you can use the Like keyword with a wildcard
to exclude any value in the field that starts with, contains anywhere
in the field, or ends with, that 5 value. Note, because it is Text
datatype, the value must be encloses within quotes "5".
WHERE tblItemTypes.ItemTypeID Not Like "5*"
will exclude records that begin with the 5, i.e. 5, 53, 569, etc.
If the value to exclude is just "5", then there is no need for a wild
card nor the Like keyword.
WHERE tblItemTypes.ItemTypeID Not "5"
If the datatype is a Number datatype, then do not use the Like keyword
nor the quotes..
WHERE tblItemTypes.ItemTypeID Not 5
Also the Where clause goes after the Select, not after the Union
Select...
I'll guess that the 5 is a number, not text.
SELECT tblItemTypes.ItemTypeID,tblItemTypes.ItemTypeName
FROM tblItemTypes
WHERE tblItemTypes.ItemTypeID Not 5
UNION SELECT 0,"All Types" FROM tblItemTypes
ORDER BY ItemTypeName;
Note: if one of the values sorts before "All Types", for example,
"alabaster", your "All Types" will NOT be first in the list.
To sort first, you could use "<All Types" or " All Types", etc.