Hey I wrote a programme that would add, delete, save and search through records in a database (recordset) however I was doing it in a team. My task was to add the search function to the programme, which I have however I am having problems with adding an error message for when somebody types a word/anything that isn't in the database/recordset.
So for example in the textbox(txtFindBox.Text) if they type "ashbndash" it would come up with an error message, i've commented out my own error message boxs but tell me where i'm going wrong please :(
Here's the code for the find button.
Private Sub cmdFindDB_Click()
adoCustomer.Recordset.MoveFirst
If optLastName.Value = True Then
adoCustomer.Recordset.Find "LastName='" & txtFindBox.Text & "'"
'Else
'MsgBox ("NO RECORD FOUND")
End If
If OptFirstName.Value = True Then
adoCustomer.Recordset.Find "FirstName='" & txtFindBox.Text & "'"
'Else
'MsgBox ("NO RECORD FOUND")
End If
End Sub
edit: Just like to say the problem is that every time I hit the button 'find' it comes up with the message "NO RECORD FOUND" in a msgbox even though it finds the answer, it also comes up with that msgbox if you type in gibberish too.
Thanks for your time
Regards Haroon