UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Getting duplicate groups in report when group field is empty.    
 
   
fish3s
post Aug 3 2007, 01:31 PM
Post #1

UtterAccess Member
Posts: 37



I have a report based on a simple parameter query. A control button on a form runs the query which asks for the fiscal period to be entered and then displays the report. One of the criteria for grouping in the report is DEPT. Many of the records have no DEPT values. The report keeps giving two groups of DEPT for no value in that field. I want to see the records for no value entered in the DEPT field but cannot understand why it breaks them into two groups. At first I thought that maybe a user had enter a space in one or more of those records in that field, but I haven't found that to be the case. Is there something about grouping on a field that has some empty fields in records that can cause this?
Go to the top of the page
 
+
balaji
post Aug 3 2007, 01:36 PM
Post #2

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



You are probably seeing two groups because for some records the DEPT field is null and in other records it is a zero-length string. There is a difference between the two. The way to get around this is to convert the null values to a zero-length string by using the nz() function. Then group by this new calculated field.
Go to the top of the page
 
+
fish3s
post Aug 3 2007, 01:49 PM
Post #3

UtterAccess Member
Posts: 37



Thanks for the guidance. I'm pretty new at this. Could I put the code in the control source box? Something like:

Nz(DEPT)

Thanks,
fish3s
Go to the top of the page
 
+
balaji
post Aug 3 2007, 02:00 PM
Post #4

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



No, in the query where you do the grouping, you need to group by nz(DEPT,"").
Go to the top of the page
 
+
fish3s
post Aug 3 2007, 02:33 PM
Post #5

UtterAccess Member
Posts: 37



Sorry I'm so dense about this. In the query it won't allow entering anything in the Group By line in the DEPT field other than the operators that are in the pull-down box. When I put it in the criteria line, the query returns no records, when in fact there should be many.

Thanks for helping,
fish3s
Go to the top of the page
 
+
balaji
post Aug 3 2007, 02:46 PM
Post #6

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



What is the SQL you have for the query right now? Are you doing the grouping in the report by using the sorting and grouping toolbar item? Then where you are currently grouping by DEPT, just replace that with nz(DEPT,"") so that the grouping is done by this expression rather than what you have right now.
Go to the top of the page
 
+
fish3s
post Aug 3 2007, 02:56 PM
Post #7

UtterAccess Member
Posts: 37



The grouping is being done in the report but the grouping toolbar only allows what is in the pull-down which is the fields of the underlying table which is the source for the parameter query which asks for the FISCAL PERIOD.

The report is grouping on FISCAL PERIOD, DEPT, and then PROBLEM CODE in that order and then sorts on PROBLEM CODE.
Go to the top of the page
 
+
balaji
post Aug 3 2007, 03:02 PM
Post #8

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



Don't click on the drop-down arrow. Just type in the expression I have given you in place of DEPT.
Go to the top of the page
 
+
fish3s
post Aug 3 2007, 03:06 PM
Post #9

UtterAccess Member
Posts: 37



It doesn't allow me to in the Group, Sort, and Total toolbar in the report.
Go to the top of the page
 
+
balaji
post Aug 3 2007, 03:12 PM
Post #10

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



OK, maybe this is a new feature in Access 2007. I have only Access 2003 on my computer here and I can type in expressions rather than choosing something from the dropdown. I will get someone who has Access 2007 to help you out. Sorry for the delay.
Go to the top of the page
 
+
datAdrenaline
post Aug 3 2007, 03:23 PM
Post #11

UtterAccess Editor
Posts: 15,978
From: Northern Virginia, USA



How did you type it? in the Grouping and Sorting dialog, you need to type it in the form of an expression:

=Nz(Dept,"")

I do have A2007 (its at home and I am at work) and I vaguely remember doing this just yesterday ...
Go to the top of the page
 
+
balaji
post Aug 3 2007, 03:43 PM
Post #12

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



Thanks for jumping in, Brent. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thanks.gif)
Go to the top of the page
 
+
datAdrenaline
post Aug 3 2007, 10:53 PM
Post #13

UtterAccess Editor
Posts: 15,978
From: Northern Virginia, USA



Just to expand a bit as I am now at home and can verify ... in the Grouping & Sorting dialog ... er um "Frame" at the bottom of the screen ... when you display the field list you will see the word "Expression" at the bottom of the pop up window that displays the field list ... click on that word and you will see the expression builder pop up ... it is there that you will type in"

=Nz(Dept, "")

... Or ... you can just add a calculated column to your Query/SQL that is the recordsource for your form, then you will be able to select the calculated column's alias in the field listing
Go to the top of the page
 
+
fish3s
post Aug 6 2007, 11:51 AM
Post #14

UtterAccess Member
Posts: 37



Success! I hadn't noticed the word "Expression" at the bottom of the pop up window that displays the field list. It didn't like the syntax at first, but after some experimenting it worked. It took it when I added brackets around the first expression "Dept"

=Nz([Dept],"")

The report now only shows one group of records with no Dept specified that equals the total of the two groups displayed previously.

Thanks so much for your help Balaji and Brent!

fish3s
Go to the top of the page
 
+
balaji
post Aug 6 2007, 12:28 PM
Post #15

UtterAccess VIP
Posts: 5,635
From: Chicagoland, USA



You are welcome. Good luck with your project. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
Go to the top of the page
 
+
datAdrenaline
post Aug 6 2007, 11:54 PM
Post #16

UtterAccess Editor
Posts: 15,978
From: Northern Virginia, USA



(IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 10:10 PM