dbTalk Databases Forums  

Filter Question

comp.databases.ms-access comp.databases.ms-access


Discuss Filter Question in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike
 
Posts: n/a

Default Filter Question - 04-22-2009 , 07:54 AM






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.

Reply With Quote
  #2  
Old   
Allen Browne
 
Posts: n/a

Default Re: Filter Question - 04-22-2009 , 08:21 AM






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" <info (AT) baltworld (DOT) com> wrote

Quote:
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.


Reply With Quote
  #3  
Old   
Mike
 
Posts: n/a

Default Re: Filter Question - 04-22-2009 , 09:38 AM



On Apr 22, 9:21*am, "Allen Browne" <AllenBro... (AT) SeeSig (DOT) Invalid> wrote:
Quote:
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 -
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.


Reply With Quote
  #4  
Old   
Allen Browne
 
Posts: n/a

Default Re: Filter Question - 04-22-2009 , 11:07 AM



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" <info (AT) baltworld (DOT) com> wrote

On Apr 22, 9:21 am, "Allen Browne" <AllenBro... (AT) SeeSig (DOT) Invalid> wrote:
Quote:
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.



Reply With Quote
  #5  
Old   
Mike
 
Posts: n/a

Default Re: Filter Question - 04-22-2009 , 11:47 AM



On Apr 22, 12:07*pm, "Allen Browne" <AllenBro... (AT) SeeSig (DOT) Invalid>
wrote:
Quote:
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 -
Thanks!! Worked like a charm without the table or query name, but with
everything else!!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.