creating a search on a database

04-16-2004, 04:33 AM
Hello all,

i am currently trying to work on a program in visual basic that will display a search criteria window, from here the user can select what attribute from a database they wish to search, then type the criteria of the search.
*the attribute list is in a combobox, and the criteria is typed into a textbox*

the user then clicks a search button

this is where i am stuck, what i now need to do is link to the database, and run a query depending on what the user has selected.

can anyone please help with this?

thank you,


04-16-2004, 04:57 AM

For tutorials on working with ADO see the FAQ section.
The recordset you'll have to open will look close to:

"Select * From Table1 Where Field1= '" & cboSearch & "'"


04-16-2004, 05:01 AM
Hi Rob,
I think that you need the following 2 lines:

Set MyDataBase = OpenDatabase(App.Path & "\<dbname>.mdb")
Set rs = MyDataBase.OpenRecordset("<sql statement>")

in the 1st replace <dbname> with the access database name you have
in the 2nd replace <sql statement> with a sql query with your attribute and your criteria
the rs recordset will have all the returned data

04-16-2004, 07:09 AM
I would recommend using ADO and not DAO. If you are just starting to program, it is best to start with the most flexible, newest technology.

A list of ADO connection strings can be found here:

And, if you go to our knowledge base, in the tutors section, there is a nice ADO for beginners tutorial you can start with.

And, for a nice review of SQL, you can start here:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum