473,387 Members | 1,342 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,387 software developers and data experts.

Creating a User Friendly Search Interface

I'm trying to design a form with a few key fields on it that will allow the user to enter any portion one or more of those fields (i.e. if they enter "Elm" in the address field, it would match all addresses on Elm Street, Elm Drive, etc.), and then upon clicking on a button it will bring up the list of all records that match the criteria. To do this I invoke a query that uses the 'like "*" & [field name] & "*"' syntax for each of the fields. The only problem is that if a field in the dataset is null, the record is excluded even if the the corresponding field on the search form was left blank.

So for example:
If they enter "Elm" in the address field, and enter Smith in the name field and leave the Phone Number field blank, it should bring up all the records for Smiths with Elm addresses, regardless of their phone number, even is the phone number field in the data set hasn't been filled in for some of the matches. What happens is that all records with null values are excluded.

Is there a better way to approach this, or is there a syntax that will avoid the problem?

Thank you.
Jul 12 '07 #1
5 3606
Rabbit
12,516 Expert Mod 8TB
Use Nz(FieldName, "") Like ...
Jul 12 '07 #2
puppydogbuddy
1,923 Expert 1GB
I'm trying to design a form with a few key fields on it that will allow the user to enter any portion one or more of those fields (i.e. if they enter "Elm" in the address field, it would match all addresses on Elm Street, Elm Drive, etc.), and then upon clicking on a button it will bring up the list of all records that match the criteria. To do this I invoke a query that uses the 'like "*" & [field name] & "*"' syntax for each of the fields. The only problem is that if a field in the dataset is null, the record is excluded even if the the corresponding field on the search form was left blank.

So for example:
If they enter "Elm" in the address field, and enter Smith in the name field and leave the Phone Number field blank, it should bring up all the records for Smiths with Elm addresses, regardless of their phone number, even is the phone number field in the data set hasn't been filled in for some of the matches. What happens is that all records with null values are excluded.

Is there a better way to approach this, or is there a syntax that will avoid the problem?

Thank you.

Yes, by building SQL substrings for each search item and then concatenating the substrings into one SQL string. Each substring is set to "" if the return to the substring is null;then before the compound string is about to be put to gether the fields with the empty strings are excluded from the composite string.

The link below is to an excellent multifield search facility with source code so that you can see how it works.

http://allenbrowne.com/ser-62.html
Jul 12 '07 #3
Yes, by building SQL substrings for each search item and then concatenating the substrings into one SQL string. Each substring is set to "" if the return to the substring is null;then before the compound string is about to be put to gether the fields with the empty strings are excluded from the composite string.

The link below is to an excellent multifield search facility with source code so that you can see how it works.

http://allenbrowne.com/ser-62.html

Thank you. I think this will be very helpful.
Jul 13 '07 #4
Use Nz(FieldName, "") Like ...
Hey, it worked! Thanks.
Jul 13 '07 #5
Rabbit
12,516 Expert Mod 8TB
Hey, it worked! Thanks.
Not a problem, good luck.
Jul 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wraith Daquell | last post by:
Hello all. I am working on a project that involves an Office-like interface; that is, the user will be able to create objects such as textareas and be able to resize, move, manipulate, etc. them....
2
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks...
10
by: Deano | last post by:
I think that just about sums it up. Is there a fix/workaround for this?It's quite annoying behaviour and not user-friendly.thanksMartin
17
by: Fabrice | last post by:
Hi ! I'm looking for a tutorial on how to create a DLL in C (not C++). I don't know whether i can use C for this purpose, but i didn't find any post telling me that i cannot use C. So, if it is...
24
by: Rob R. Ainscough | last post by:
VS 2005 I have: ClickOnce deployment User's that hate and or don't want to use an IE Client (don't blame them) I don't see how ASPX web pages are going to survive? With .NET 2.0 and clickonce...
11
by: MLH | last post by:
Anyone ever experiement importing WAB data directly into A97? Would lke a chance to look at any work done in this arena.
2
by: alternativa | last post by:
Hi, I have a following problem: I need to create a set of classes which together can make a data base. Say we have: class Student { string sname; int snumber; Student *snextptr; ...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
4
by: neb | last post by:
Hi all, Does anybody know if there is anything like Access that is xml powered? Having MS Access in mind, I dream of an engine that will store the xml document, and their schema, and enable...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.