MS Acess SQL - where clause to get year from date based on the year - data located in MS access form
Posted
by primus285
on Stack Overflow
See other posts from Stack Overflow
or by primus285
Published on 2010-04-19T18:53:54Z
Indexed on
2010/04/19
19:13 UTC
Read the original article
Hit count: 248
OK, back again. I have a problem getting a drop down list to populate based on information in two fields.
I have got the SQL correct as to Select
just one year if I put DateValue('01/01/2001') in both places, but I am trying now to get it to grab the year data from the MS access form - another drop down named "cboYear".
I'd hate to have to do something in VB, unless necessary.
so far I have gotten this to pull up something (its always incorrect)
SELECT DISTINCT Database_New.ASEC
FROM Database_New
WHERE Database_New.Date>=DateValue('01/01/' & [cboYear])
And Database_New.Date<=DateValue('12/31/' & [cboYear]);
and
SELECT DISTINCT Database_New.ASEC
FROM Database_New
WHERE Database_New.Date>=DateValue('01/01/' + [cboYear])
And Database_New.Date<=DateValue('12/31/' + [cboYear]);
SELECT DISTINCT Database_New.ASEC
FROM Database_New
WHERE Database_New.Date>=DateValue('01/01/' AND [cboYear])
And Database_New.Date<=DateValue('12/31/' AND [cboYear]);
both give errors saying that it is too complex to compute.
Its probably something simple, but where do I go from here?
© Stack Overflow or respective owner