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.
5 3606
Use Nz(FieldName, "") Like ...
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
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.
Use Nz(FieldName, "") Like ...
Hey, it worked! Thanks.
Hey, it worked! Thanks.
Not a problem, good luck.
Sign in to post your reply or Sign up for a free account.
Similar topics
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....
|
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...
|
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
|
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...
|
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...
|
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.
|
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; ...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
| |