FIltering error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a command box with an event procedure to filter based on a specific
value in the Status field. My problem is that when the specific value is not
in any of the records instead of showing me that the status does not exist,
it goes to back to my form but without all the controls and fields. I only
get a greyed out box. How do I correct this? Here is my code.

Private Sub CmdFilterHolds_Click()
On Error GoTo Err_CmdFilterHolds_Click
DoCmd.ApplyFilter , "Partner_Data.Status = 'HOLD'"
Exit_CmdFilterHolds_Click:
Exit Sub
Err_CmdFilterHolds_Click:
MsgBox Err.Description
Resume Exit_CmdFilterHolds_Click
End Sub
 
Try this code in place of the DoCmd.Apply filter line. It applies the
filter, and tests if there are no records. If so, it pops up a message and
turns the filter off again.

Me.Filter = "Partner_Data.Status = 'HOLD'"
Me.FilterOn = True
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No Matches"
Me.FilterOn = False
End If
 
Back
Top