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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying a access database from vb

Status
Not open for further replies.

Egglar

Technical User
Apr 4, 2002
88
GB
hi,

i want to query a ms access database from a vb program, im using MS Visual Basic 6.

Idealy i want to end up with the database file and an exe.

The database is called dbPartsList.mdb and contains one table (tblPartsList)

i have created a text box and two lables on the vb form (txtInput, lblDesciption and lblPrice1)

when the user enters a part number into txtInput and hits cmdSearch, i want it to search the PartNumber column of tblPartsList and output the part description and price found in the columns Description and Price1 respectivley, into lblDescription and lblPrice1

Ive had a few attempts at this after reading through some of the FAQ on this site but with no success, i cant even load the database that alone search it, any code snippits would be very helpfull, many thanks
 
an easy way to add the "Data" Control on to the form. And then have the text boxes bounded to the data field in the table:

And as far as searching:

in the lost focus event of the name:

dim rst as recordset
and to navigate
rst.MoveFirst, MoveLast, rst.FindFirst, etc...

Please let me know if this helped you :)

Tekno
Wireless Toyz
Ypsilanti, Michigan
 
to be perfectly honest that makes no sense to me, do i have to declare the database file name and path etc or how?
i can do basic vb programming, but when it comes to intergrating databases, i have no clue.
thanks for your reply tho
 
TeknoSDS mentioned using the data controller. It is a control that is standard with VB and is used to handle your connection to the database.

Add a data controller to you form from the toolbox. Set the database and recordsource properties to whatever they need to be.

Then bind your labels and text boxes to the data controller and choose the correct data field for them.

This should allow you to navigate through your records.

To search you would do something like this:

Data1.Recordset.FindFirst "Field=Criteria"

This is pretty generic but you should be able to figure it out.
 
Ok thanks for your helps, ive got it done now, and i actually learnt something while doing it, many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top