![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am trying to apply a filter to a subset of records via a macro. The macro calls the filter for current year records and previous year records based on a YEAR field. The filter WORKS when I apply " year like "2008" " for the previous year however I do not want to have to contuinlly change the previous year value each year. When I enter YEAR Like Now() it FAILS. Any help is appreciated. |
#3
| |||
| |||
|
|
Try: * * [Table1].[YEAR] = Year(Date()) - 1 Including the table name and the square brackets should help alleviate the fact that YEAR is a reserved word. -- Allen Browne - Microsoft MVP. *Perth, Western Australia Tips for Access users -http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Mike" <i... (AT) baltworld (DOT) com> wrote in message news:41f9191f-034b-4e1b-815e-9371a28c2cf1 (AT) o20g2000vbh (DOT) googlegroups.com... I am trying to apply a filter to a subset of records via a macro. *The macro calls the filter for current year records and previous year records based on a YEAR field. *The filter WORKS when I apply " year like "2008" " for the previous year however I do not want to have to contuinlly change the previous year value each year. When I enter YEAR Like Now() it FAILS. *Any help is appreciated.- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
Try: [Table1].[YEAR] = Year(Date()) - 1 Including the table name and the square brackets should help alleviate the fact that YEAR is a reserved word. "Mike" <i... (AT) baltworld (DOT) com> wrote in message news:41f9191f-034b-4e1b-815e-9371a28c2cf1 (AT) o20g2000vbh (DOT) googlegroups.com... I am trying to apply a filter to a subset of records via a macro. The macro calls the filter for current year records and previous year records based on a YEAR field. The filter WORKS when I apply " year like "2008" " for the previous year however I do not want to have to contuinlly change the previous year value each year. When I enter YEAR Like Now() it FAILS. Any help is appreciated.- Hide quoted text - - Show quoted text - |
#5
| |||
| |||
|
|
You may be able to use the query name, or the name of the source table. In this context, you might even get away without the query/table name. (It is likely to give problems in VBA code through.) -- Allen Browne - Microsoft MVP. *Perth, Western Australia Tips for Access users -http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org."Mike" <i... (AT) baltworld (DOT) com> wrote in message news:9f38cd94-c951-4123-9658-f363a247a19f (AT) e23g2000vbe (DOT) googlegroups.com... On Apr 22, 9:21 am, "Allen Browne" <AllenBro... (AT) SeeSig (DOT) Invalid> wrote: Try: [Table1].[YEAR] = Year(Date()) - 1 Including the table name and the square brackets should help alleviate the fact that YEAR is a reserved word. "Mike" <i... (AT) baltworld (DOT) com> wrote in message news:41f9191f-034b-4e1b-815e-9371a28c2cf1 (AT) o20g2000vbh (DOT) googlegroups.com.... I am trying to apply a filter to a subset of records via a macro. The macro calls the filter for current year records and previous year records based on a YEAR field. The filter WORKS when I apply " year like "2008" " for the previous year however I do not want to have to contuinlly change the previous year value each year. When I enter YEAR Like Now() it FAILS. Any help is appreciated.- Hide quoted text - - Show quoted text - OK, That helps however I neglected to tell you that the macro calls the filters in a contunious form, via an option group. *I dont believe that I have a table to refrence unless your meaning the control source (query) of the form... thanks for the help.- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |