Tuesday, 8 December 2015

Search Records in Database (By Name or ID)-Visual Basic6.0 -Ms Access

How to search records in the database by entering either Name or Roll No/ID -Visual Basic 6.0 and MS Access Database Application.
 In my earlier tutorial,I demonstrate-How to Add,Delete,Update and Clear Records.,https://youtu.be/tYS7uncH8Ds
Now ,I am going to Add one more feature to this Application.
So In this tutorial,I demonstrate-How can you search a particular record in the database by entering either Roll No/ID or Name in the Textbox on the form.
 Following features covered:
1.How to make necessary changes in database connection (ADODC) for searching records in the database.
2.How to search records by Roll No/ID in the Database.
3.If Record is not available in the database,Then A warning Message box (Record Not Found-search for any other Roll No/ID) Appears.
4.How to search existing records by Name in the database



Source Code:
Double click on Go Button and Write the following code.
Private Sub gobtn_Click()
Studentdb.RecordSource = "select * from Student_Info where RollNo ='" + rollsearch.Text + "'or Name ='" + rollsearch.Text + "'"
Studentdb.Refresh
If Studentdb.Recordset.EOF Then
MsgBox "Record Not Found ,Please Try any other Rollno", vbInformation
Else
Studentdb.Caption = Studentdb.RecordSource
End If
End Sub


  If you have any queries,suggestions or problems,please leave comments.
 for more Visual Basic tutorials,Visit Youtube Channel:https://www.youtube.com/user/sandydehrian Computer Gyan Blog:http://selfcomputerlearning.blogspot.in/ Do share and Subscribe to my channel :-)