Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting my msgbox even if the search request is found 1

Status
Not open for further replies.

dragnut

Technical User
Dec 27, 2000
125
US
I'm using vb4-16(since work has crappy puters), and I search a database for a serial number and if not found pops up a msgbox saying so. But even if the number is found the msgbox comes up anyway.
I Know the answer is so simple that i'm overlooking it, but since I work 12 hours a day, its kinda hard to even see when I get to working on this app. Any help would earn my undying gratitude :)

Here is the code...

'Search for a serial number
On Error Resume Next
Message = "Enter the Serial Number you want to find."
Title = "S/N Search"
Dim searchtext As Integer
searchvalue = InputBox(Message, Title)
If searchvalue = "" Then MsgBox "Please enter a Serial Number to find": Exit Sub 'MsgBox "Please enter a Serial Number to find"
searchtext = Val(searchvalue)
Data1.Recordset.FindFirst "SerialNumber = " & searchvalue
If Not searchvalue Then MsgBox "No Record Found!"
End Sub
 
Change the last line to
Code:
    If Data1.Recordset.NoMatch Then MsgBox "No Record Found!"
Rick Sprague
 
Thanks Rick, I knew it had to be so simple. Guess I justt have to get some sleep before attempting to do anything :)

Dragnut
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top