i am using ADODB to connect an access database to my forms. i have the folloing code which searches the database table for a barcode. it searches and displays correctly, until you put in a non existant barcode, then it comes up with error 3021. eof bof error. it highlights the line
text1.text = RS!Barcode
however, if i move the lines
text1.text = RS!Barcode
text2.text = RS!Name
below the if statement for checking eof and bof, then not having the barcode in the database will show the "record not found" messege box, then display the previous error. however, it will not display the text in the boxes if the barcode is correct.
here is the code, any help is well apprecciated
Private Sub cmdFind_Click()
Dim tr As String
RS.MoveFirst
tr = InputBox("Enter Barcode", "Find")
If tr > 0 Then
tr = "barcode='" & tr & "'"
RS.Find tr
Text1.Text = RS!Barcode
Text2.Text = RS!Name
Else
If RS.EOF Or RS.BOF = True Then
MsgBox "Record was not Found", vbInformation + vbOKOnly, "No Match"
End If
End If
End Sub