Solved

VB Access Linear search

Posted on 2004-04-01
3
565 Views
Last Modified: 2013-12-25
Hey I need a feature to search a database using a linear search then display the result in the textboxes linked to the data control but I have no clue how to. Can someone give me the code?

Form name = frmeditfile
Data control name = datappointment
Column to search = Telephone Name
Search var = Got from input box.

Thanks
0
Comment
Question by:Mercurtio
3 Comments
 
LVL 8

Expert Comment

by:bramsquad
ID: 10734440
if you are using ado, this could work

dim i as integer, conn as new ADODB.connection, rcd as new ADODB.recordset
dim valuefrominputbox as string
'make sure to open connection to db here


valuefrominputbox = inputbox()
for i = 0 to rcd.recordcount - 1
if rcd.Fields.Item(0).Value = valuefrominputbox then
     me.textbox.text += rcd.Fields.Item(0).Value + vbcrlf
end if
next

the "0" in rcd.Fields.Item(0).Value references the first column, so you would change that to whatever the column is you want to compare.  also, the +vbcrlf just creates a new line, so it would look like this in your textbox

value1
value2
value3

if youre using vb6, use this for the if statement

if rcd![Telephone Name].Value = valuefrominputbox then

someone please correct me if i made any syntax errors, i didnt test this, but i think its right

~bramsquad

0
 

Author Comment

by:Mercurtio
ID: 10736684
I'm not sure what ADO is i'm using the Data control with arrows each side of it to connect to the database then each textbox connects to the data control via Datasource.

I need it to set the data control to the position where it found the item to update all the other text boxes connected to it not put the searchitem in a textbox.
0
 
LVL 45

Accepted Solution

by:
aikimark earned 100 total points
ID: 10739443
AdoDataControl1.Recordset.Find "fieldname = searchvalue"

Note: you will need to add delimiters around searchvalue for text and date field searches.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question