VBA ,Coding filter by selection 
Author Message
 VBA ,Coding filter by selection

I am having a problem coding a field in access2000. I am applying a
Filter by Selection using VBA within access that goes as follows:

Private Sub Category_Change()

Select Case Category.Text
    Case "First Nations"
        DoCmd.ApplyFilter , "Category = 'First Nations'"
    Case "Independent"
        DoCmd.ApplyFilter , "Category = 'Independent'"
    Case "Company"
        DoCmd.ApplyFilter , "Category = 'Company'"
    Case "College/University"
        DoCmd.ApplyFilter , "Category = 'College/University'"
    Case "Correspondence"
        DoCmd.ApplyFilter , "Category = 'Correspondence'"
    Case "Junior High School"
        DoCmd.ApplyFilter , "Category = 'Junior High School'"
    Case "Senior High School"
        DoCmd.ApplyFilter , "Category = 'Senior High School'"
    Case "Special Needs"
        DoCmd.ApplyFilter , "Category = 'Special Needs'"
    Case "Other"
        DoCmd.ApplyFilter , "Category = 'Other'"
    End Select

End Sub

What is happening is that the filter is working properly, although, the
record that is displayed when the "category" is changed is then changed
into the "category" that the filter is applied to.

example:

Category: First Nations     <--Category Record is currently in
SchoolName: School1
Street: 1234 Main st

When you select another entry in the "Category" drop down list then the
filter is applied, although it also changes the current record (above)
to the field selected to filter by(eg: Independent) and lists all the
other files matching the "category" filter as well

Category: Independent  <-- When putting on filter to view all
SchoolName: School1        independent schools the current record then
Street: 1234 Main st          changes to Independent

To summerize, the filter is working properly. I just need some way so
that the current record isnt changed(updated) when it is applied

I have tried "form_main.Refresh" at the end of the code but it doesnt
seem to do anything

if you need to see what the form looks like, you can view it at
http://www.*-*-*.com/

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 VBA ,Coding filter by selection
Help Please!!!!


Quote:

> I am having a problem coding a field in access2000. I am applying a
> Filter by Selection using VBA within access that goes as follows:

> Private Sub Category_Change()

> Select Case Category.Text
>     Case "First Nations"
>         DoCmd.ApplyFilter , "Category = 'First Nations'"
>     Case "Independent"
>         DoCmd.ApplyFilter , "Category = 'Independent'"
>     Case "Company"
>         DoCmd.ApplyFilter , "Category = 'Company'"
>     Case "College/University"
>         DoCmd.ApplyFilter , "Category = 'College/University'"
>     Case "Correspondence"
>         DoCmd.ApplyFilter , "Category = 'Correspondence'"
>     Case "Junior High School"
>         DoCmd.ApplyFilter , "Category = 'Junior High School'"
>     Case "Senior High School"
>         DoCmd.ApplyFilter , "Category = 'Senior High School'"
>     Case "Special Needs"
>         DoCmd.ApplyFilter , "Category = 'Special Needs'"
>     Case "Other"
>         DoCmd.ApplyFilter , "Category = 'Other'"
>     End Select

> End Sub

> What is happening is that the filter is working properly, although,
the
> record that is displayed when the "category" is changed is then
changed
> into the "category" that the filter is applied to.

> example:

> Category: First Nations     <--Category Record is currently in
> SchoolName: School1
> Street: 1234 Main st

> When you select another entry in the "Category" drop down list then
the
> filter is applied, although it also changes the current record (above)
> to the field selected to filter by(eg: Independent) and lists all the
> other files matching the "category" filter as well

> Category: Independent  <-- When putting on filter to view all
> SchoolName: School1        independent schools the current record then
> Street: 1234 Main st          changes to Independent

> To summerize, the filter is working properly. I just need some way so
> that the current record isnt changed(updated) when it is applied

> I have tried "form_main.Refresh" at the end of the code but it doesnt
> seem to do anything

> if you need to see what the form looks like, you can view it at
> http://www3.telus.net/intrigue/Jarrett

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VBA Code for filtering on two fields

2. How do I apply a filter to a SUBFORM (In VBA CODE)

3. VBA Code to filter forms

4. Code Filter By Form in VBA

5. Problem Filtering in VBA (includes code)

6. VBA Code for Date selection from calendar object

7. Pop-up Filter Selection

8. Filtering a form with a combo box selection

9. A VB Filter by Selection?

10. A VB Filter By Selection?

11. Filter by Selection

12. DTPicker does not allow Filter By Selection in access 2002

 

 
Powered by phpBB® Forum Software