tweetyangel00
Technical User
Can anyone tell me why the code below is not working? I am not getting any errors when I step through it. I have a button that removes all of the filters on the form & subforms and I want the current record to have the focus after the filters are removed. Based on the help files I looked at this should work.
Any help is greatly appreciated! Ty!
*******************************
Private Sub cmdRemoveFilter_Click()
'removes filter from form and subforms and returns you to your current record
'Groves 23-Feb-2011, 16-Mar-2011
On Error Resume Next
Dim sfrm As SubForm
Dim rst As DAO.Recordset
Dim strCriteria As String
'find record to bookmark
strCriteria = "[TextField] = '" & Me.TextField & "'"
Set rst = Me.RecordsetClone
rst.MoveFirst
rst.FindFirst strCriteria
'removes filter from main form whick moves focus to the first record in the form
DoCmd.ShowAllRecords
'removes filter from 1st subform
Set sfrm = Forms!frm_IssueTrackingData!subfrm_IssueTracking_Data_Studies_v2
With sfrm
sfrm.SetFocus
DoCmd.ShowAllRecords
End With
'removes filter from 2nd subform
Set sfrm = Forms!frm_IssueTrackingData!subfrm_IssueTrackingData_Lots_v2
With sfrm
sfrm.SetFocus
DoCmd.ShowAllRecords
End With
'return control to the main form and return to the bookmarked record
Me.TextField.SetFocus
DoCmd.GoToControl "TextField"
Me.Bookmark = rst.Bookmark
Set rst = Nothing
End Sub
*************************************************
Any help is greatly appreciated! Ty!
*******************************
Private Sub cmdRemoveFilter_Click()
'removes filter from form and subforms and returns you to your current record
'Groves 23-Feb-2011, 16-Mar-2011
On Error Resume Next
Dim sfrm As SubForm
Dim rst As DAO.Recordset
Dim strCriteria As String
'find record to bookmark
strCriteria = "[TextField] = '" & Me.TextField & "'"
Set rst = Me.RecordsetClone
rst.MoveFirst
rst.FindFirst strCriteria
'removes filter from main form whick moves focus to the first record in the form
DoCmd.ShowAllRecords
'removes filter from 1st subform
Set sfrm = Forms!frm_IssueTrackingData!subfrm_IssueTracking_Data_Studies_v2
With sfrm
sfrm.SetFocus
DoCmd.ShowAllRecords
End With
'removes filter from 2nd subform
Set sfrm = Forms!frm_IssueTrackingData!subfrm_IssueTrackingData_Lots_v2
With sfrm
sfrm.SetFocus
DoCmd.ShowAllRecords
End With
'return control to the main form and return to the bookmarked record
Me.TextField.SetFocus
DoCmd.GoToControl "TextField"
Me.Bookmark = rst.Bookmark
Set rst = Nothing
End Sub
*************************************************