?
Solved

searching for 2 fields in VB

Posted on 2009-12-18
11
Medium Priority
?
175 Views
Last Modified: 2013-12-25

hello group,

I'm having a problem with results of a search. In the program there is a way of finding customers by entering a keyword either as first-name or last-name or ... that works fine. basically, what it is done is as:

0) strValue = str //entered by user
1) strFname = GetField("FirstName")  //read value of  current record
2) If Instr(strFname, strValue) > 0 Then ....

Now, I need to do search for cases where both firstname and lastname are entered together in search box. I have done:

0) strValue = str //entered by user
1) strFname = GetField("FirstName")  //read value of  current record
2) strLname = GetField('LastName")  //read last name too
3) strKeyword = strFname =+ " " + strLastName
2) If Instr(strFname, strValue) > 0 Then ....  //strValue now has something as "Kim Walker"

This sometimes works and sometimes doesn't. what is the best approach?

Regards,
ak
0
Comment
Question by:akohan
  • 5
  • 4
10 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 26078466
You need to split the strValue in two seperate words and then need to serach in strfname and strLname using OR condition so wherever match found it will show the result as true
0
 

Author Comment

by:akohan
ID: 26078491

that is what I did in the first place using split() and mystring() as as array then looping using UBOUND() but changed it.

I will get back to you soon.

Thanks,
ak
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 26078500
ok. let us know if you face problem in that
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:akohan
ID: 26078505


sure. thanks!
0
 
LVL 10

Expert Comment

by:joriszwaenepoel
ID: 26078513
In your example code, you are searching only for the First Name using strFname instead of strKeywork.
Don't know if that is just an error in your message or also in your real code.
0
 

Author Comment

by:akohan
ID: 26078517

One major issue is that sometimes a last name has two or three pieces, such as Tom Gomez Harton
and I am using split() to tokenize works base on " " so that I will have an array with 3 elements.

Tom, Gomez, Harton

but I need Tom, Gomez Harton.

any idea?
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 total points
ID: 26078551
try

My_Array=split(My_String," ",2)
will split in two

refer
http://www.plus2net.com/asp-tutorial/array-split.php
0
 

Author Comment

by:akohan
ID: 26079022

Thanks!!!
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 26079068
your problem get solved or not?
0
 

Author Comment

by:akohan
ID: 26079109

I don't have access to the computer now but will do it tomorrow.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
What we learned in Webroot's webinar on multi-vector protection.
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…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

578 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