hi
I am using this code to call and apply a filter.
If the are no records that match the filter search then i would like a msgbox that tell the user so and the form show all the records.
At present is there is no records when the filter is applied I get a blank form.
Public Function MyFilter()
DoCmd.OpenForm "dlgFilter", , , , , acHidden
Dim dlg As Form
Set dlg = Forms!dlgYFilter
fConfirm = False
dlg!chkYear = False
dlg!cboYear.Visible = False
dlg!chkTerm = False
dlg!cboTerm.Visible = False
dlg!chkModule = False
dlg!cboModule.Visible = False
dlg!txtSQL = ""
dlg.Visible = True
On Error GoTo FilterErr:
Do
DoEvents
Loop Until Not dlg.Visible
On Error GoTo 0
If fConfirm Then
If Len(FilterString) > 0 Then DoCmd.ApplyFilter , FilterString
Exit Function
FilterErr:
If Err <> OBJECT_NO_LONGER_EXISTS Then
MsgBox Err & " " & Error
End If
End If
End Function
I am using this code to call and apply a filter.
If the are no records that match the filter search then i would like a msgbox that tell the user so and the form show all the records.
At present is there is no records when the filter is applied I get a blank form.
Public Function MyFilter()
DoCmd.OpenForm "dlgFilter", , , , , acHidden
Dim dlg As Form
Set dlg = Forms!dlgYFilter
fConfirm = False
dlg!chkYear = False
dlg!cboYear.Visible = False
dlg!chkTerm = False
dlg!cboTerm.Visible = False
dlg!chkModule = False
dlg!cboModule.Visible = False
dlg!txtSQL = ""
dlg.Visible = True
On Error GoTo FilterErr:
Do
DoEvents
Loop Until Not dlg.Visible
On Error GoTo 0
If fConfirm Then
If Len(FilterString) > 0 Then DoCmd.ApplyFilter , FilterString
Exit Function
FilterErr:
If Err <> OBJECT_NO_LONGER_EXISTS Then
MsgBox Err & " " & Error
End If
End If
End Function