Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Searching an access database


I'm new to database programming in visual basic I'm in need of some help performing a search. Here's what I would like to do:

I have a form with a textbox and a command button, I would like to make it so that a user can input the name of a person (as this is a customer DB) and have the program perform a search of all records and return those records with the name specified. (I would like to attempt to search through records when the button is clicked)

If possible I would like to use the Data control to aide in the search as I'm not real keen on the ADO control yet. I've tried using the .seek and .find first properties of the data control with no success... I think I've got all required data in the database though to perform a search (ie: Fields to index & a primary key)

As I understand, you also need a data grid control to output results. Is this true?

Any help is greatly appreciated!

- Jared


  • fg_raifg_rai Member Posts: 2
    i have here a sample code that search for the desired data from a database table:

    Data1.RecordSource = "select * from Authors where Au_ID ='" +Text1.Text+ "'"

    Text2.Text = Data1.Recordset.Fields("Author")

    note: the data1 is the name of your data control. you have to specify what are you searching in the where clause of your select statement. in here i used the biblio database as an example, the author table in particular. the code searches for the author whose id(Au_ID) appears on text1 (text1.text)--- (it is the textbox where the user will enter the data of what he searches. this will be the search criteria).
    you may or may not use a datagrid. in my example i used another textbox (text2.text)to output the name of the author("Author").

Sign In or Register to comment.