Searching In VB

I have three three text boxes namely first name, last name and DOB

 and one datagrid in which i am displaying the  table "students"

I want when the user enters any value in any of the three boxes ( either the full first name, or last name or either the first three letters of  first  or last name , or only DOB),  and click on "Search" button:-

The datagrid will only search  on the basis  of above criteria  and will display the values  from the database... in the datagrid...........................................

Please help me in VB only  as i need it urgently
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
in your Search button, try add like:

SQL = "Select * from yourTable "
tmp = " WHERE "
If FirstName.Text <> "" then tmp = tmp & " FirstName Like '%" & Replace$(FirstName.Text,"'","''") & "%' And "
If LastName.Text <> "" then tmp = tmp & " LastName Like '%" & Replace$(LastName.Text,"'","''") & "%' And "
If DOB.Text <> "" then tmp = tmp & " DOB = #" & DOB & "# And "     'Change # to ' if necessary, depends on your database using

If tmp = " WHERE " then
    tmp = ""
   tmp = left$(tmp, len(tmp) - 4)
End if
SQL = SQL & tmp

If rs.state = adStateOpen Then rs.Close
rs.Open SQL, conn, adOpenKeyset, adLockOptimistic

Set datagrid1.DataSource = rs

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajender123Author Commented:
Thanks.. for this...  i want that when the serch results come in datagrid...(since i have  multiple values  of  the same student  with different dates) so the datagrid  will display all the values......................... of  ame student with different visit dates..........

Now  i   want if i  select one row...... all the records will be displayed in the text boxes:- namely

first name
last name
visit date

Also, the search results  should also be present  at the same time....................

Can u please help  me out in VB.............................................
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>Now  i   want if i  select one row...... all the records will be displayed in the text boxes:- namely
I think this is the new question from this thread, you can try:

1. Open a New Question with this requirement or
2. Increase this question's points

so that we can help here.

rajender123Author Commented:
I have  increased the points  also
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.