Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set/Remove Filter

Status
Not open for further replies.

wreded

Technical User
Dec 18, 2001
119
US
i haven't seen this in the forum yet so here goes...

i don't like the way Access deletes records on the fly. i'd rather they just be marked and then removed when the user decides they're not useful anymore. Form opens with a table, one field of which is a marker "Deleted." i'd like to code a button that toggles a filter between showing Deleted records and hiding Deleted records.

So far no luck...
Code:
Private Sub btnFilterDeleted_Click()
'    Me.FilterOn Me.Deleted = False
    'DoCmd ApplyFilter(Me.Deleted = False)
    'strfilter = False
    Me.FilterOn = Not Me.FilterOn
    If Me.FilterOn = True Then
        Me.Filter = Deleted = False
    Else
        Me.Filter = Deleted = True
    End If
    'Me.Filter = IIf(Me.FilterOn = True, Me.Deleted = False, Me.Deleted = True)
    '[Forms]![frmMainForm].Filter = strfilter
    '[Forms]![frmMainForm].FilterOn = True
    
End Sub
i keep commenting things out so if i happen on the right combination i don't have to go back to square one. The last two lines do work, but don't allow me to toggle it on and off, just off.
Any ideas?
Thanks,
Dave
 
A starting point:
Me.Filter = "[Deleted] = False"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya wreded . . .

Perhaps the following:
[ol][li]In the [blue]Caption[/blue] property of the button, enter [blue]View Deleted[/blue].[/li]
[li]In the [blue]On Click[/blue] event of the button, copy/paste the following:
Code:
[blue]   Dim prpON As Property, Cap As Property
   
   Set prpON = Me.Properties("FilterOn")
   Set Cap = Me!btnFilterDeleted.Properties("Caption")
   
   If prpON Then
      prpON = False
      Cap = "View Deleted"
   Else
      Me.Filter = "[Deleted] = True"
      prpON = True
      Cap = "View All"
   End If
   
   Set prpON = Nothing
   Set Cap = Nothing[/blue]
[/li]
[li]Save the form and perform your testing![/li][/ol]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
PHV & TheAceMan1
First off, thanks for both responses. i tried them both and can't seem to get Yours to work TheAceMan1; PHV's worked right off the bat. i think i was close, but not within horseshoe range.
i'll keep trying Yours TheAceMan1. Moving between Access03 at home and Access07 at work keeps me wondering just where i am all the time.
Thanks!
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top