Could someone help me write an error handler please? I feel like I've tried every which way and I'm just not getting the code right.
I have a button on a form that calls a Sub
Sub cmdSearch_Click
Call Search
End Sub
Sub Search ()
Dim strCriteria, ... ... ...
'''---lotsa code---
'''...
task = "select * from [qryFinancialsByMonth2] where (" & strCriteria & ")"
Me.FilterOn = True
DoCmd.ApplyFilter task
End Sub
If the strCriteria is blank when the task filter is applied, then Access says "Run-time error 3075, Syntax error missing operator in query expression..."
I'd like to replace that MsgBox with one saying "Please select at least one criteria for the search." with a simple OK button to click.
As I said, I've tried several different things. I'm not sure any of them are worth posting. But here's one of them:
On Error GoTo Error_SearchIf IsNull strCriteria ThenMsgBox "Please select at least one criteria to search for.", vbOKOnlyEnd IfExit Sub'''...Error_Search:If Err.Number = 3075 ThenResume Exit_SubEnd If End Sub