473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using Access With An SQL Find Function

Hello all,

Hope someone can help me with this! It would be much appreciated!

Am using a Access 2000 Database (actcs2002.mdb) integrated into VB6. I am
having trouble writing a Find command (when the user provides a part of a
surname into a TextBox and clicks the Find button, it should return the
surname of the customer and their appropriate customer number in a ListBox)

A few examples would be:

Surnames: Cust_No:
Woods 1
Wolf 2
Byrnes 3

So if the user inputs ' Wo* ' - it would display:

Woods 1
Wolf 2

Or if the user inputs ' Byrnes ' - it would display:

Byrnes 3

I think you all get the picture anyways [ by the way, hope i didn't over
simplify (if that's the right word) things with that example ]. I am using
an SQL statement to find the customer in the database and output their
surname and number.

Here's what i have so far.

Private Sub cmdFind_Click()
Set conn1 = New ADODB.Connection
conn1.Provider = "microsoft.jet.oledb.4.0;"
conn1.ConnectionString = App.Path & "\accts2002.mdb"
conn1.Open

x = "Select * From Customer Where Sname Like " & txtSname.Text

Set rs2 = New ADODB.Recordset
rs2.Open x, conn1
rs2.MoveFirst

Do While Not rs2.EOF
y = rs2!c_no & " " & rs2!sname
lstResults.AddItem y
rs2.MoveNext
Loop
End Sub

Jul 17 '05 #1
1 8039
Brian,

Use wildcards,

x = "Select * From Customer Where Sname Like '%" & txtSname.Text & "%'"
greets John

--
-----------------------------------------------
John Lauwers
Robotronic Nv
jo**@robotronic.be

"Brian Basquille" <tb**************@eircom.net> schreef in bericht
news:eY*****************@news.indigo.ie...
Hello all,

Hope someone can help me with this! It would be much appreciated!

Am using a Access 2000 Database (actcs2002.mdb) integrated into VB6. I am
having trouble writing a Find command (when the user provides a part of a
surname into a TextBox and clicks the Find button, it should return the
surname of the customer and their appropriate customer number in a ListBox)
A few examples would be:

Surnames: Cust_No:
Woods 1
Wolf 2
Byrnes 3

So if the user inputs ' Wo* ' - it would display:

Woods 1
Wolf 2

Or if the user inputs ' Byrnes ' - it would display:

Byrnes 3

I think you all get the picture anyways [ by the way, hope i didn't over
simplify (if that's the right word) things with that example ]. I am using
an SQL statement to find the customer in the database and output their
surname and number.

Here's what i have so far.

Private Sub cmdFind_Click()
Set conn1 = New ADODB.Connection
conn1.Provider = "microsoft.jet.oledb.4.0;"
conn1.ConnectionString = App.Path & "\accts2002.mdb"
conn1.Open

x = "Select * From Customer Where Sname Like " & txtSname.Text

Set rs2 = New ADODB.Recordset
rs2.Open x, conn1
rs2.MoveFirst

Do While Not rs2.EOF
y = rs2!c_no & " " & rs2!sname
lstResults.AddItem y
rs2.MoveNext
Loop
End Sub

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: chris.dunigan | last post by:
I'm looking for an example of how to execute an existing DTS­ package from an ASP (VB)script and would appreciate any and all response. ­I don't even know if it's possible Thanks - Chuck...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
10
by: eyh5 | last post by:
Hi, My C code (running on Soalris Unix) has some "segmentation fault" that I wish to use purify to do it. I poked around the web, and found some information about adding some lines in a Makefile...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
5
by: debbie | last post by:
I have three combo boxes on a subform. I have tried setting them up so that when the user clicks in the combo box the curser moves to the left. I have searched the posts and can find nothing that...
7
by: nhkam | last post by:
I am using MS Access 2007 I have a transaction table which holds all records with posting date on each of them. I used a make table query to find out the max date hold in the transaction table and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.