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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering and Unfiltering

Status
Not open for further replies.

Jengo

Programmer
Apr 17, 2000
100
US
I have a database that I filter a certain records through on to a form. I use the following code to link the form:

stDocName = "Form Name"
stLinkCriteria = "this field" & "this forms field"
DoCmd.OpenForm stDocName, , , stLinkCriteria

I want to be able to make the form go back to having all records after I filter it. When the form opens it filters to my specifications, and then I want to be able to look at the rest of records, how do I do that?
 
you can add a command button to the form and attach code to toggle the FilterOn property between true or false

Private Sub cmdApplyFilter_Click()
If Me.FilterOn = False Then
Me.FilterOn = True
Else
Me.FilterOn = False
End If
End Sub

PaulF
 
Instead of filtering, try opening the form then move to the first record that matches your criteria. For example the following code (which pasted poorly) works:

DoCmd.OpenForm "frmClientManagement"
Forms!frmClientManagement.RecordsetClone.FindFirst "[tblClient].[fldClientID] = 2"
Forms!frmClientManagement.Bookmark = Forms!frmClientManagement.RecordsetClone.Bookmark

Rob Marriott
rob@career-connections.net
 
The only problem with removing a filter, as PaulF had suggested, is that once the filter is removed the form will requery and thus move to the first record. The only way around this - to have access to the selected record and every other record - is to open the form then do a FindFirst. If I am wrong - please let me know.

Rob Marriott
rob@career-connections.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top