I need help with the following code. I need it to be able to handle the After_Update event when the text box is a Null, or if there is no match I would like to just cancel the whole process.
Such as:
If rs.NoMatch Then
MsgBox "No Match"
"Cancel entire After_Update procedure"
Cancel = True gives me a syntex error.
Maybe there is something wrong with my code. Thanks for any help I can get on this. Or suggestions on how I should do it.
Private Sub txtDateSearch_AfterUpdate()
On Error GoTo Err_txtDateSearch_AfterUpdate
Form_Current
Form.DataEntry = False
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ActivityDate] = #" & Me![txtDateSearch] & "#"
If rs.NoMatch Then
MsgBox "There is no match for your search", vbCritical
Else
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.txtDateSearch = Null
Me.tblActivities_Subform.SetFocus
End If
Exit_txtDateSearch_AfterUpdate:
Exit Sub
Err_txtDateSearch_AfterUpdate:
If Err.Number = 3075 Then
Exit Sub
Else
MsgBox Err.Number & Err.Description
Resume Exit_txtDateSearch_AfterUpdate
End If
End Sub
Such as:
If rs.NoMatch Then
MsgBox "No Match"
"Cancel entire After_Update procedure"
Cancel = True gives me a syntex error.
Maybe there is something wrong with my code. Thanks for any help I can get on this. Or suggestions on how I should do it.
Private Sub txtDateSearch_AfterUpdate()
On Error GoTo Err_txtDateSearch_AfterUpdate
Form_Current
Form.DataEntry = False
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ActivityDate] = #" & Me![txtDateSearch] & "#"
If rs.NoMatch Then
MsgBox "There is no match for your search", vbCritical
Else
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.txtDateSearch = Null
Me.tblActivities_Subform.SetFocus
End If
Exit_txtDateSearch_AfterUpdate:
Exit Sub
Err_txtDateSearch_AfterUpdate:
If Err.Number = 3075 Then
Exit Sub
Else
MsgBox Err.Number & Err.Description
Resume Exit_txtDateSearch_AfterUpdate
End If
End Sub