473,670 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exclude record if query yields no results

98 New Member
say i want to query a few fields from a table for the purposes of a report. how might i have the query only return records that have data in at least one of the fields to prevent the repot from having many blank pages?
Aug 10 '12 #1
18 3280
twinnyfo
3,653 Recognized Expert Moderator Specialist
In the criteria of one or more of the fields of your query set it to "Is Not Null". This should return only records that have data in them.
Aug 10 '12 #2
trixxnixon
98 New Member
sweet i will try this.
Aug 10 '12 #3
trixxnixon
98 New Member
it works, but only if all of the fields i have in the query have data. if one is null the record is excluded. how do exclude only the records where all fields are blank?
Aug 13 '12 #4
twinnyfo
3,653 Recognized Expert Moderator Specialist
For each of the fields you want to check for data, us the "Is Not Null" Criteria, but on a separate cirteria line in the query builder... Please see the attachment....

Attached Images
File Type: jpg Query.jpg (41.1 KB, 1414 views)
Aug 13 '12 #5
zmbd
5,501 Recognized Expert Moderator Expert
The SQL would be somethig like:

Using a table named "Table1"
with [ID_t1] autnumber - pk
with [startdate_t1] as date field
with [something_t1] as text(50)

then
Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.ID_t1, 
  2.    Table1.startdate_t1, 
  3.    Table1.something_t1
  4. FROM Table1
  5. WHERE ((Not (Table1.ID_t1) Is Null))
  6.   OR ((Not (Table1.date_t1) Is Null))
  7.   OR ((Not (Table1.something_t1) Is Null));
-z
Aug 13 '12 #6
trixxnixon
98 New Member
here is my sql below. it still returns items that were not selected on the form. what might cause this?
Oct 15 '12 #7
twinnyfo
3,653 Recognized Expert Moderator Specialist
What do you mean by "items that were not selected on the form"? I thought this was a query to return only non-all-null records?
Oct 15 '12 #8
trixxnixon
98 New Member
I apologize, I was trying to re edit my post when you replied.
I added a column that has a tracking number parameter that is selected from a form. I want the query to return only the records that have the corresponding tracking number, with the subsequent fields. . . with at least one that has content. Null or blank.
Does that make more sense?
Oct 15 '12 #9
trixxnixon
98 New Member
I had some problems posting the sql within the tags.

Expand|Select|Wrap|Line Numbers
  1.  SELECT [Workshop Survey].[Course Code], 
  2.    [Workshop Survey].[communicate comments], 
  3.    [Workshop Survey].[manner comments], 
  4.    [Workshop Survey].[materials comments], 
  5.    [Workshop Survey].[objectives comments], 
  6.    [Workshop Survey].[participation comments], 
  7.    [Workshop Survey].[objective2 Comments], 
  8.    [Workshop Survey].[prep comments]
  9. FROM [Workshop Survey]
  10. WHERE ((([Workshop Survey].[Course Code])=
  11.    [Forms]![Workshop]![code])) 
  12.    AND ((([Workshop Survey].[communicate comments]) 
  13.       Is Not Null)) 
  14.    OR ((([Workshop Survey].[manner comments]) 
  15.       Is Not Null))
  16.    OR ((([Workshop Survey].[materials comments]) 
  17.       Is Not Null)) 
  18.    OR ((([Workshop Survey].[objectives comments]) 
  19.       Is Not Null)) 
  20.    OR ((([Workshop Survey].[participation comments]) 
  21.       Is Not Null)) 
  22.    OR ((([Workshop Survey].[objective2 Comments]) 
  23.       Is Not Null)) 
  24.    OR ((([Workshop Survey].[prep comments]) Is Not Null));
Oct 15 '12 #10

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

Similar topics

1
2063
by: John Sway | last post by:
I'm writing a web-based "Query analyser" tool for our company intranet. It allows a user to type any SQL statement in a form, and execute it over the Web. The SQL can be a query that returns results (e.g: SELECT * FROM members) or it can be a T-SQL (e.g: UPDATE/DELETE/INSERT). What I want to know is, is there any way using either SQLCommand or DataSet or any of the other ADO.NET classes to determine what kind of query it is, BEFORE...
1
6571
by: Big Time | last post by:
I've got a crosstab query that counts the number of values in one of my tables. However, rather than giving me the number of instances of each record, what I would like is for each value to display, separated by a comma. For example, in the query is a row is named BC and a column named Vancouver, it currently displays "4" for the number of instances that Vancouver appears combined with the BC field. However, what I would like to display...
1
3011
by: SC | last post by:
I'm developing a site that may eventually have a very large database of users (hopefully, but who knows). It will be a community website where users can search each other (think Friendster, Classmates, every dating site out there, etc.). Often there will be queries with multiple joins and sometimes may include a few fulltext searches. Each page of results will have a limited number of results displayed (obviously). As I understand it,...
0
1449
by: sicapitan | last post by:
Hi There, not sure if this can be done with SQL or if there is an SQL crossover I have two tables: Table "record": id, record_id, data1, data2 Table "subrecord": id, record_id, name, value
5
16254
abouddan
by: abouddan | last post by:
Hi all I am working on an accounting project using MS Access 2000, that demands to calculate many fields in a spesific record. The problem: The query I am using returns many records and for each record 3 fields, let's say Data1, Data2, Data3. In the form related to this query I have 5 text boxes.The three text boxes are bound to the query. The two other text boxes are for displaying calculations, the first one displays the sum of the three...
4
3127
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the first query where Item is Null. I use a subreport for the details, and the results display correctly. However, the Report_Details event of the subreport is executed about 2 or 3 times more than I would expect (I think 3 times when I have a
3
1685
by: heckstein | last post by:
I have created a query in MS Access 2003 that is pulling training records for our company that includes training hour calculation. One field I am pulling is the instructor name. Many courses have multiple instructors, which means I am getting multiple records for a single course. I need to capture all of the instructor names, but I only want a single record for each course due to the hour calculation. I would like the report to generate only one...
0
1431
by: k01902 | last post by:
The-Center-3004 23/11/2009 9:50 23/11/2009 9:51 SOP Status The-Center-3004 23/11/2009 9:52 23/11/2009 10:00 SOP Status The-Center-3004 23/11/2009 9:53 23/11/2009 10:00 Out of order The-Center-3004 04/12/2009 10:49 04/12/2009 10:52 SOP...
1
3423
by: henricirc | last post by:
Ok so here it goes, I'm not sure if this can be done but I'm trying. I am trying to create a form "pickpatients" with a button (newsearch) and a listbox (list2) to run a query of my Visits1 table where all my patient visit data is stored. I want to be able to generate the results of this query in list2. I would then like to be able to click or highlight a result from the query and press another button on the form to generate a report with all...
4
2250
by: mbedford | last post by:
How can I make a query return zero values when there are no results? The first level of queries returns data from tables based on a selection made in a form and reported in a different query. The base query, qryPrintCostAssets, returns all data from tblAssets based on a selection in a form. qryPrintCostAssets.ID is key to the rest of the queries pulling their data. SELECT * FROM tblAssets WHERE...
0
8471
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, 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...
0
8903
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, 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...
1
6216
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5686
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();...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1795
bsmnconsultancy
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...

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.