On Mon, 29 Jan 2007 00:17:29 GMT, Jimmy wrote:
I'm trying to run a query that will show only records where the year in a
date field equals the current year:
SELECT tblSideJob.SideJobID, tblSideJob.Date FROM tblSideJob WHERE
(((tblSideJob.Date)=Year(Date())));
This does not display any records at all. The field tblSideJob.Date is a
date/time field
1) That's because Year(Date()) does not return a Date datatype value,
but rather a variant (Integer) datatype value, i.e. 2007 is not a
date. See VBA help.
Change the Where clause to:
WHERE Year(tblSideJob.Date)=Year(Date())
2) Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:
109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail