Solved

VB Access Linear search

Posted on 2004-04-01
3
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

691 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