Try testing for no records returned
EDIT: I see you have leading and trailing spaces in the Query,(and also in the Command4_Click Event code) vis:Code:Private Sub Form_Load() Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\user\Desktop\NEW DB\FAITH.mdb;Persist Security Info=False" cn.Open Set rs = New ADODB.Recordset With rs .ActiveConnection = cn .CursorLocation = adUseClient .CursorType = adOpenKeyset .LockType = adLockOptimistic .Open (" select * from faith where employee_id= ' " & Form2.Text1.Text & " '") End With If Not (rs.BOF And rs.EOF) Then DataGrid1.Refresh DataGrid1.DataSource = rs Else MsgBox "Query Returned No Records searching for Employee-ID:" & vbNewLine & Form2.Text1.Text End If End Sub
I suspect you mean:Code:..... where employee_id= ' " & Form2.Text1.Text & " '"
or evenCode:..... where employee_id= '" & Form2.Text1.Text & "'"
which will remove any leading or trailing spaces from the TextBox contents.Code:..... where employee_id= '" & Trim$(Form2.Text1.Text) & "'"




Reply With Quote