VB Code:
Private Sub Command1_Click() Dim Search As String Dim sql As String Search = InputBox("Enter Client ID", "Search Record") data1.Recordset.FindFirst "[Client ID]= '" & Search & "'" sql = "SELECT * FROM Table1 WHERE [Client ID] = '" & Search & "'" data1.RecordSource = sql data1.Refresh If data1.Recordset.NoMatch Then MsgBox "Record Not Found!", vbExclamation, "Search Record" Else MsgBox "Record Found!", vbInformation, "Search Record" End If End Sub
I wrote the above code to retrieve more than one records of a same client, and these records will be showed in a data grid. When record found/match, there will be a mesage box which displays "Record Found!", but the problem is when there is no record match, the message box still displays "Record Found!". I can't see anything wrong with the code/statement, any suggestion to make the message box display "Record Not Found!" when there is no record match?
Thanks in advance!




Reply With Quote