I have a button to reset my form after filtering.
If there is at least a record in result, then reset form...it works perfectly. However, if the result returns no record, it seems doing the job in the back but the text I enter in the form is staying there still.
How come it doesn't work properly on my form?
This is the code to search
If there is at least a record in result, then reset form...it works perfectly. However, if the result returns no record, it seems doing the job in the back but the text I enter in the form is staying there still.
How come it doesn't work properly on my form?
Code:
Private Sub cmdReset_Click()
Me.txtKeywords = Null
Me.cboRptType = Null
Me.cboArea = Null
Me.txtRecordCount = Null
Me.ogSort = 1
Me.Filter = "(False)"
Me.FilterOn = True
Me.OrderByOn = False
Me.txtKeywords.SetFocus
End sub
This is the code to search
Code:
Private Sub cmdSearch_Click()
Me.Filter = Left$(strWhere, lngLen)
Me.FilterOn = True
Me.OrderBy = strOrderBy
Me.OrderByOn = True
If (Me.Recordset.RecordCount > 0) Then
Me.FormFooter.Visible = True
Else
'if no records found
MsgBox "No record found based on your search criteria."
Me.cmdReset.SetFocus
End If
Exit_cmdSearch_Click:
Exit Sub
Err_cmdSearch_Click:
MsgBox Err.Description
Resume Exit_cmdSearch_Click
End Sub