borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (import in VB some forms from Access)Next Topic (About Transaction) New Topic New Poll Post Reply
AndreaVB Forum : Database : search access database
Poster Message
ryansanders2002
Level: Big Cheese

Registered: 26-10-2004
Posts: 21

icon search access database

I use VisData to create a access database then use the form designer for the database. The only problem is that there is so search button. What code would I need to search the database for a given value.(basically the same as the search button in visdata itself)

20-11-2004 at 11:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon Re: search access database

It all depends if you are using ADO or DAO, if you are using Data control/ADODC control or creating recordsets through code.

' Data control - find record based on string search
Data1.Recordset.FindFirst "Name='" & Text1.Text & "'"

' DAO recordset -  find record based on numeric search
rs.FindFirst "Age=" & text1.text

' ADODC control - find record (string search) that is begining with text1.text value
Adodc1.Recordset.Find "Name Like '" & Text1.Text & "*'"

' ADO recordset - find record (string search) that has text1.text value anywhere in it.
rs.Find "Name Like '*" & text1.text & "*'"


Note that when searching strings you need to put value to be searched for between single quotes ("Name='Ryan'") and when searching for numeric values, no single quotes are used ("Age=22")

One thing to add, unlike DAO FindFirst method, ADO Find method has 4 parameters: criteria, SkipRows, searchDirection and start... Check documentation on how they are used.

[Edited by Goran on 21-11-2004 at 02:50 AM GMT]

____________________________
If you find the answer helpful, please mark this topic as solved.

21-11-2004 at 01:44 AM
View Profile Send Email to User Show All Posts | Quote Reply
ryansanders2002
Level: Big Cheese

Registered: 26-10-2004
Posts: 21
icon Re: search access database

Cool,Thanks

21-11-2004 at 02:38 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : search access database
Previous Topic (import in VB some forms from Access)Next Topic (About Transaction) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder