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 BC As String

tr = InputBox("Enter Barcode", "Find")
If tr > 0 Then
tr = "barcode='" & tr & "'"
RS.Find tr

Text1.Text = RS!Barcode
Text2.Text = RS!Name


If RS.EOF Or RS.BOF = True Then
MsgBox "Record was not Found", vbInformation + vbOKOnly, "No Match"

End If
End If
End Sub

Edited by Dani: Formatting fixed

11 Years
Discussion Span
Last Post by skalra63
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.