?
Solved

VB Access Linear search

Posted on 2004-04-01
3
Medium Priority
?
579 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 46

Accepted Solution

by:
aikimark earned 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses

762 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