473,399 Members | 3,038 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,399 software developers and data experts.

Applying filter from form in query

48
Hello,

I've got a form like this:

Name: _(free text input)__
Adress: _(free text input)_
City: _(free text input)_

When clicking a Apply Filter button on the form a query is started. The Query contains the 3 fields above with [forms]![Form1]![Name] /[Adress]/[City] filters. When entering data in the formfields and hitting the button the query shows the results as filtered in the formfields.

When I leave 1 of the formfields empty the query shows no result because it can't match the null-data. But this is just the thing I need..

When I don't enter a value in 1 of the formfields I want the query to don't filter that field at all. For example when I enter Name and City, let's say John and Amsterdam, I want the query to show the result of all Johns from Amsterdam and not leave the result blanc because the Adress is null..

Hope someone can help! Thanks, Sander
Oct 10 '06 #1
6 5463
PEB
1,418 Expert 1GB
Hi Sander,

But in my autofilter forms, when i filter, when there is no specified value and it's blanc so there is not filter running on!

There is is Null not is null to specify if I want the empty or not empty fields...

When empty it's no filter activated on he field...

Maybe in your list has the space that is choosen???

Best regards
Oct 14 '06 #2
sanniep
48
Hi Sander,

But in my autofilter forms, when i filter, when there is no specified value and it's blanc so there is not filter running on!

There is is Null not is null to specify if I want the empty or not empty fields...

When empty it's no filter activated on he field...

Maybe in your list has the space that is choosen???

Best regards
Hi PEB,

Thanks for your help again!

When I leave the textbox empty and put a msgbox to the button with the value of the textbox as messageboxtext Access says "Invalid use of Null-data" so the value of the textbox when I leave it blanc is Null..

The question is how to let the query know that if I leave the textbox blanc it has to show everything instead of nothing..

I've tried a lot of iif's to the query where I say 'if textbox is blanc then value is not null". I've tried:

iif([forms]![form1]![txt_item] Is Null;Is Not Null;[forms]![form1]![txt_item])
iif([forms]![form1]![txt_item] ="";Is Not Null;[forms]![form1]![txt_item])
iif([forms]![form1]![txt_item] ="";<>"";[forms]![form1]![txt_item])
iif(IsNull([forms]![form1]![txt_item]);Is Not Null;[forms]![form1]![txt_item])
iif(IsNull([forms]![form1]![txt_item]);<>"";[forms]![form1]![txt_item])

All of these iif's return an empty query when ran with a blanc textbox..

I've also tried filling the textbox with default value "no filter" and using iif's:
iif([forms]![form1]![txt_item]="no filter";Is Not Null;[forms]![form1]![txt_item])
iif([forms]![form1]![txt_item]="no filter";<>"";[forms]![form1]![txt_item])

The Autofilter function you describe is just what I want. Maybe I should use VB, but how??

Hope you can help..

Sander
Oct 16 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Try this

iif(Not IsNull([forms]![form1]![txt_item],[forms]![form1]![txt_item])


Hi PEB,

Thanks for your help again!

When I leave the textbox empty and put a msgbox to the button with the value of the textbox as messageboxtext Access says "Invalid use of Null-data" so the value of the textbox when I leave it blanc is Null..

The question is how to let the query know that if I leave the textbox blanc it has to show everything instead of nothing..

I've tried a lot of iif's to the query where I say 'if textbox is blanc then value is not null". I've tried:

iif([forms]![form1]![txt_item] Is Null;Is Not Null;[forms]![form1]![txt_item])
iif([forms]![form1]![txt_item] ="";Is Not Null;[forms]![form1]![txt_item])
iif([forms]![form1]![txt_item] ="";<>"";[forms]![form1]![txt_item])
iif(IsNull([forms]![form1]![txt_item]);Is Not Null;[forms]![form1]![txt_item])
iif(IsNull([forms]![form1]![txt_item]);<>"";[forms]![form1]![txt_item])

All of these iif's return an empty query when ran with a blanc textbox..

I've also tried filling the textbox with default value "no filter" and using iif's:
iif([forms]![form1]![txt_item]="no filter";Is Not Null;[forms]![form1]![txt_item])
iif([forms]![form1]![txt_item]="no filter";<>"";[forms]![form1]![txt_item])

The Autofilter function you describe is just what I want. Maybe I should use VB, but how??

Hope you can help..

Sander
Oct 16 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
By the way the IIf statement is separated by commas not semi colans.
Oct 16 '06 #5
sanniep
48
By the way the IIf statement is separated by commas not semi colans.
Hello mmccarthy,

Thanks for your advise. I'm applying the expressions from the Access Query designwindow, not from SQL or VB. In this rookie 'can't function wihout a GUI' interface I have to use semi colans, commas aren't accepted..

But I've tried your iif(Not IsNull([Forms]![Form1]![txt_item]);[Forms]![Form1]![txt_item]). After a run Access modifies the iif to:

iif(Not([Item])=IsNull([Forms]![Form1]![txt_item]);[Forms]![Form1]![txt_item])

You would expect that the criteria is only applied when the textbox is filled, when left blanc it doesn't apply any criteria but the bad news is that this expression also results in an empty query when I leave the textbox blanc.

Do you have other suggestions? Appreciate your help, thanks!
Oct 16 '06 #6
Ragbrai
10
Try this:

Like iif(IsNull([forms]![form1]![txt_item]),"*",[forms]![form1]![txt_item])

Good Luck
Dec 28 '06 #7

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

Similar topics

1
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside...
3
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
4
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced...
4
by: MS | last post by:
I'm having trouble applying a filter to a subform. I create a String in a Module based on various selections on the form. Clicking a button on the "stand alone form" that changes the filter...
1
by: lorirobn | last post by:
Hi, I have a report that works just fine. Now I would like to add the capability to choose selection criteria to limit what is displayed. I created several reports that do this, but they used...
1
by: lorirobn | last post by:
Hi, I have a list box on a form, whose row source points to a separate query. The query refers to a field on the form to filter records on the list box, like such: WHERE tblA.DesignType = !!...
1
by: jcf378 | last post by:
Is it possible to set a main-form with an embedded subform to "Filter by Form", subsequently enter the desired variables in fields in BOTH the main-form and subform, and then save the resulting...
7
kcdoell
by: kcdoell | last post by:
Hello: I have a form that I want to open using a filter that I have created. I have done this usually by pointing the record source of the form to the query/filter that I created. In this new...
13
by: bkberg05 | last post by:
Hi - I have a form called Vendor (tied to table with same name). Each vendor_id can belong to more than one 'category'. So there's a table called Vendor_Category which contains just vendor_id and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
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,...
0
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.