Hi ladies and gents. I'm hoping anyone will be able to help me in a
small access problem I am having. Let me try to explain:
I have a form with textboxes which I use as criteria for a query. The
form is used to allow my users to search for specific company names or
if left blank, all the company names, so I built my criteria as
follows: Like [forms].[formname].[texboxname] & chr(42)
The form works ok if I am looking for a spesific company name, but when
left blank, the results excludes Is Null records, as the wildcard wants
to have a record with any characters in it.
Heres my Question. How could I build the criteria to say if the form
field is left blank, bring back all records including null values.
I hope anyone can be of any help or guidance. - Regards, Eddie Holder 7 10991
Set up the WHERE clause of the query like this:
WHERE (([forms].[formname].[texboxname] Is Null)
OR ([MyField] Like [forms].[formname].[texboxname] & "*"))
If the text box on the form is null, the first part of the expression
returns True, so the condition is True for all records. If the first part is
not true (i.e. the text box has something in it), only fields that match are
returned.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
<ed**********@m ousetraining.co m> wrote in message
news:11******** **************@ r2g2000cwb.goog legroups.com... Hi ladies and gents. I'm hoping anyone will be able to help me in a small access problem I am having. Let me try to explain:
I have a form with textboxes which I use as criteria for a query. The form is used to allow my users to search for specific company names or if left blank, all the company names, so I built my criteria as follows: Like [forms].[formname].[texboxname] & chr(42)
The form works ok if I am looking for a spesific company name, but when left blank, the results excludes Is Null records, as the wildcard wants to have a record with any characters in it.
Heres my Question. How could I build the criteria to say if the form field is left blank, bring back all records including null values.
I hope anyone can be of any help or guidance. - Regards, Eddie Holder
Hi Allen
Thanks a million for your response, it worked perfectly! What would
the statement look like if I created more serach fields, for example I
needed to be able to search using 5 textboxes, all individual, or if
some was completed partially, it uses the them as criteria AND
statement?
Thanks for the reply, most appreciated! Thanks, Eddie Holder
Allen Browne wrote: Set up the WHERE clause of the query like this: WHERE (([forms].[formname].[texboxname] Is Null) OR ([MyField] Like [forms].[formname].[texboxname] & "*"))
If the text box on the form is null, the first part of the expression returns True, so the condition is True for all records. If the first part is not true (i.e. the text box has something in it), only fields that match are returned.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
<ed**********@m ousetraining.co m> wrote in message news:11******** **************@ r2g2000cwb.goog legroups.com... Hi ladies and gents. I'm hoping anyone will be able to help me in a small access problem I am having. Let me try to explain:
I have a form with textboxes which I use as criteria for a query. The form is used to allow my users to search for specific company names or if left blank, all the company names, so I built my criteria as follows: Like [forms].[formname].[texboxname] & chr(42)
The form works ok if I am looking for a spesific company name, but when left blank, the results excludes Is Null records, as the wildcard wants to have a record with any characters in it.
Heres my Question. How could I build the criteria to say if the form field is left blank, bring back all records including null values.
I hope anyone can be of any help or guidance. - Regards, Eddie Holder
Provided you are carefull with the bracketing, you can extend that idea:
WHERE ((xx Is Null) OR ([Field1 = xx))
AND ((yy Is Null) OR (Field2 = yy))
AND ...
But this does get messy to maintain and inefficient to execute. A better
idea is to build the Filter for your form, or the WhereCondition for your
OpenReport (or even the SQL property for your QueryDef) from only those
boxes that have a value.
To see how it's done, download this small sample database: http://allenbrowne.com/unlinked/Search2000.zip
Requires Access 2000 or later.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Eddie Holder" <ed**********@m ousetraining.co m> wrote in message
news:11******** **************@ f6g2000cwb.goog legroups.com... Hi Allen Thanks a million for your response, it worked perfectly! What would the statement look like if I created more serach fields, for example I needed to be able to search using 5 textboxes, all individual, or if some was completed partially, it uses the them as criteria AND statement?
Thanks for the reply, most appreciated! Thanks, Eddie Holder Allen Browne wrote: Set up the WHERE clause of the query like this: WHERE (([forms].[formname].[texboxname] Is Null) OR ([MyField] Like [forms].[formname].[texboxname] & "*"))
If the text box on the form is null, the first part of the expression returns True, so the condition is True for all records. If the first part is not true (i.e. the text box has something in it), only fields that match are returned.
<ed**********@m ousetraining.co m> wrote in message news:11******** **************@ r2g2000cwb.goog legroups.com... > Hi ladies and gents. I'm hoping anyone will be able to help me in a > small access problem I am having. Let me try to explain: > > I have a form with textboxes which I use as criteria for a query. The > form is used to allow my users to search for specific company names or > if left blank, all the company names, so I built my criteria as > follows: Like [forms].[formname].[texboxname] & chr(42) > > The form works ok if I am looking for a spesific company name, but when > left blank, the results excludes Is Null records, as the wildcard wants > to have a record with any characters in it. > > Heres my Question. How could I build the criteria to say if the form > field is left blank, bring back all records including null values. > > I hope anyone can be of any help or guidance. - Regards, Eddie Holder
Thanks again Allen, its a great example of a search form, but requires
VB. I will give it a bash doing the sql statement and see where I end
up on. Appreciate your help.
Regards,
Eddie Holder
Allen Browne wrote: Provided you are carefull with the bracketing, you can extend that idea: WHERE ((xx Is Null) OR ([Field1 = xx)) AND ((yy Is Null) OR (Field2 = yy)) AND ...
But this does get messy to maintain and inefficient to execute. A better idea is to build the Filter for your form, or the WhereCondition for your OpenReport (or even the SQL property for your QueryDef) from only those boxes that have a value. To see how it's done, download this small sample database: http://allenbrowne.com/unlinked/Search2000.zip Requires Access 2000 or later.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Eddie Holder" <ed**********@m ousetraining.co m> wrote in message news:11******** **************@ f6g2000cwb.goog legroups.com... Hi Allen Thanks a million for your response, it worked perfectly! What would the statement look like if I created more serach fields, for example I needed to be able to search using 5 textboxes, all individual, or if some was completed partially, it uses the them as criteria AND statement?
Thanks for the reply, most appreciated! Thanks, Eddie Holder Allen Browne wrote: Set up the WHERE clause of the query like this: WHERE (([forms].[formname].[texboxname] Is Null) OR ([MyField] Like [forms].[formname].[texboxname] & "*"))
If the text box on the form is null, the first part of the expression returns True, so the condition is True for all records. If the first part is not true (i.e. the text box has something in it), only fields that match are returned.
<ed**********@m ousetraining.co m> wrote in message news:11******** **************@ r2g2000cwb.goog legroups.com... > Hi ladies and gents. I'm hoping anyone will be able to help me in a > small access problem I am having. Let me try to explain: > > I have a form with textboxes which I use as criteria for a query. The > form is used to allow my users to search for specific company names or > if left blank, all the company names, so I built my criteria as > follows: Like [forms].[formname].[texboxname] & chr(42) > > The form works ok if I am looking for a spesific company name, but when > left blank, the results excludes Is Null records, as the wildcard wants > to have a record with any characters in it. > > Heres my Question. How could I build the criteria to say if the form > field is left blank, bring back all records including null values. > > I hope anyone can be of any help or guidance. - Regards, Eddie Holder
Ok, one last thing, this is what my statement looks like at this stage.
It works fine for searching on model, but not make????
WHERE (((([Forms]![QueryData]![MakeName]) Is Null)) OR (((Cars.MAKE)
Like [Forms]![QueryData]![MakeName] & "*")) AND
(([Forms]![QueryData]![ModelName]) Is Null)) OR (((Cars.MODEL) Like
[Forms]![QueryData]![ModelName] & "*"));
Any ideas where I am going wrong?
Eddie
Eddie Holder wrote: Thanks again Allen, its a great example of a search form, but requires VB. I will give it a bash doing the sql statement and see where I end up on. Appreciate your help.
Regards, Eddie Holder
Allen Browne wrote: Provided you are carefull with the bracketing, you can extend that idea: WHERE ((xx Is Null) OR ([Field1 = xx)) AND ((yy Is Null) OR (Field2 = yy)) AND ...
But this does get messy to maintain and inefficient to execute. A better idea is to build the Filter for your form, or the WhereCondition for your OpenReport (or even the SQL property for your QueryDef) from only those boxes that have a value. To see how it's done, download this small sample database: http://allenbrowne.com/unlinked/Search2000.zip Requires Access 2000 or later.
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Eddie Holder" <ed**********@m ousetraining.co m> wrote in message news:11******** **************@ f6g2000cwb.goog legroups.com... Hi Allen Thanks a million for your response, it worked perfectly! What would the statement look like if I created more serach fields, for example I needed to be able to search using 5 textboxes, all individual, or if some was completed partially, it uses the them as criteria AND statement?
Thanks for the reply, most appreciated! Thanks, Eddie Holder Allen Browne wrote: > Set up the WHERE clause of the query like this: > WHERE (([forms].[formname].[texboxname] Is Null) > OR ([MyField] Like [forms].[formname].[texboxname] & "*")) > > If the text box on the form is null, the first part of the expression > returns True, so the condition is True for all records. If the first part > is > not true (i.e. the text box has something in it), only fields that match > are > returned. > > <ed**********@m ousetraining.co m> wrote in message > news:11******** **************@ r2g2000cwb.goog legroups.com... > > Hi ladies and gents. I'm hoping anyone will be able to help me in a > > small access problem I am having. Let me try to explain: > > > > I have a form with textboxes which I use as criteria for a query. The > > form is used to allow my users to search for specific company names or > > if left blank, all the company names, so I built my criteria as > > follows: Like [forms].[formname].[texboxname] & chr(42) > > > > The form works ok if I am looking for a spesific company name, but when > > left blank, the results excludes Is Null records, as the wildcard wants > > to have a record with any characters in it. > > > > Heres my Question. How could I build the criteria to say if the form > > field is left blank, bring back all records including null values. > > > > I hope anyone can be of any help or guidance. - Regards, Eddie Holder
The brackets matter when you mix AND and OR:
WHERE (([Forms]![QueryData]![MakeName] Is Null)
OR (Cars.MAKE Like [Forms]![QueryData]![MakeName] & "*"))
AND (([Forms]![QueryData]![ModelName] Is Null)
OR (Cars.MODEL Like [Forms]![QueryData]![ModelName] & "*"));
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Eddie Holder" <ed**********@m ousetraining.co m> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. . Ok, one last thing, this is what my statement looks like at this stage. It works fine for searching on model, but not make????
WHERE (((([Forms]![QueryData]![MakeName]) Is Null)) OR (((Cars.MAKE) Like [Forms]![QueryData]![MakeName] & "*")) AND (([Forms]![QueryData]![ModelName]) Is Null)) OR (((Cars.MODEL) Like [Forms]![QueryData]![ModelName] & "*"));
Any ideas where I am going wrong?
You can also check out the Solutions.mdb. Look under "Work with combo
boxes, list boxes, subforms, and subreports." for "Add (All) to a
list" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sarmin |
last post by:
Hi Pythoners...
It seems to me the Asterisk (*) sign in python means many things...
if a python code line looks like this:
def__init__(self, func, *param):
bla bla bla...
and then u have something like this:
func(*param)
|
by: Generic Usenet Account |
last post by:
Here's the requirement that I am trying to satisfy:
Handle wildcards in STL such that the wildcard entry is encountered
before non-wildcard entries while traversing containers like sets and
maps.
I have come up with two approaches, one using inheritance and the other
using composition. I am unable to decide which one is better.
The sample source code follows.
|
by: Bell, Kevin |
last post by:
I'm pulling a list of numbers from MS Excel, but occasionally if there
is no data from excel, the value is an asterisk, but I need to make it
null.
What is the best way to do that? Thus far, I'm using:
for value in myRange:
try:
intV = int(value)
|
by: AAVF |
last post by:
Hi
We have a problem with a query.
An Access database links via ODBC to a UNIX server. To speed things, we use
the ODBC to load the relevant tables to the local PC that runs Access so
that all querying is done locally.
One of the reports we run allows the user to list all invoices within a
period. They are also allowed to select a customer code and a product set on
|
by: Robert M |
last post by:
Hello,
I am having a problem when I enter a new row using data grid footer and the
data contains asterisk ('). I can use replace function, and it will not
crash the program but it shows 2 asterisk (' '). Actually it does not happen
in all footers and I can not find what is the difference, unless I turn some
property true...
Help is very much appreciated
Thank u
| |
by: David Garamond |
last post by:
Does anyone know what the SQL standard say (or doesn't say) about
division by zero for NULL?
--
dave
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
|
by: Evan |
last post by:
I am trying to put an asterisk in the Label text property but the asterisk
doesn't show up in the correct place.
If I enter "* hello" in the text property (using the designer property
pages) the label is displayed as "hello *". If I enter "3 * hello" the label
is displayed as "hello * 3".
How I get the asterisk to display in the proper location?
Thanks in advance.
|
by: striker07 |
last post by:
Someone help me how can i display a diamond shaped asterisk correctly pls. correct my program
this is my code:
Dim ctr, space, asterisk As Integer
For ctr = 1 To 9 Step 2
For space = (9 - 2) / 2 To 0
LstDisplay.AddItem (" ")
Next
For asterisk = 1 To ctr
|
by: Gilles Ganault |
last post by:
Hello
To handle an occasionnal flaky ADSL connection, I updated the
database that handles incoming calls to have a column that is set to
NULL, and then updated to either Y or N depending on whether a PHP CLI
script was able to send a notification e-mail to support.
To send an e-mail through out ISP's SMTP server, I'm using PHPMailer
2.0.0 rc3 http://phpmailer.sourceforge.net which worked fine until we
had some connection loss. I'm at...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |