Solved

Search Recordset for substrings

Posted on 2004-08-11
2
319 Views
Last Modified: 2010-05-02
Hi,
I am retrieving data form a SQL Server database in a VB6 ADO program.

SELECT NAME FROM TABLE1 WHERE NAME like " & sql1 & " ORDER BY NAME
sql1 contains the first 2 digits from a user entered string

I am searching the recordset with
rec2.Find "Name= '" & txtsearch & "' "
to position on the full user entered string (contained in txtsearch)

This works fine, if the user enters the complete name. If the user enters only a few digits, I would like to position on the first occurence of this substring.

Thanks for your help
TKL1960
0
Comment
Question by:TKL1960
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 125 total points
ID: 11770686
The Find method supports wildcard searches. So you can use something like:

   rec2.Find "Name Like '*" & txtsearch & "*'"

To find anything containing the substring specified in txtsearch.

Hope this helps.
0
 

Author Comment

by:TKL1960
ID: 11770836
Thanks for your quick answer. Works fine.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 …
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

790 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