Need a header for groups with no data

  • Thread starter Thread starter Alison via AccessMonster.com
  • Start date Start date
A

Alison via AccessMonster.com

Hi there,

I may be searching with the wrong words but I can't find any guidance from
the forums so I'm hoping someone out there can help me.

I have a very simple database which records complaints. In this there is a
field [Area], derived from a LookUp Table, to indicate the geographical area
where the complaint originated.
I have a query which I can run by date which forms the basis for a report
which shows the complaint details, sorted by geographical area and everything
is working fine EXCEPT ..... in the months when there are no complaints from
a particular area my report only shows the header for the areas which have
data.

Is there any way I can get Access to print the Group Header for all the areas
that I have listed in the LookUp Table so that even when there is no data,
the report will still show the area with a total of 0 in the footer?

Thanks
Alison
 
Hi Alison,

please post the SQL for your query

from the menu: View, SQL

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Hi Crystal,

I think this is what you want (and my thanks for explaining where to find it).
I'm not an Access professional and struggle with a lot of the simple stuff
although things got a lot easier when I found this website.

Look forward to your response.
Best regards
Alison

SELECT [Report Log].[Record No], [Report Log].[Date Reported], [Report Log].
Originator, [Report Log].Area, [Report Log].[Report Type], [Report Log].
Equipment, [Report Log].[Report Details], [Report Log].Status
FROM [Report Log]
WHERE ((([Report Log].[Date Reported]) Between [Start Date] And [End Date]))
ORDER BY [Report Log].[Record No];

Hi Alison,

please post the SQL for your query

from the menu: View, SQL

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Hi there,
[quoted text clipped - 16 lines]
Thanks
Alison
 
Hi Alison,

you're welcome :)

Make a table:

*YMs*
YM, text, 4

then, create records for (ie:)
0601
0602
0603
etc

where the first 2 characters are year and the second 2
characters are month.

Now, make a query to "add a YM field to your table" so you
can use that to link:

Name --> qReportLogYM
SQL --> SELECT *, format([Date Reported],"yymm") FROM
[Report Log];

Now, make another query on top of that to get what you want:

Name --> qReportLogSource
SELECT Yms.YM, Rpt.[Record No], Rpt.[Date Reported],
Rpt.Originator, Rpt.Area, Rpt.[Report Type], Rpt.
Equipment, Rpt.[Report Details], Rpt.Status
FROM qReportLogYM as Rpt RIGHT JOIN YMs ON Rpt.YM=Yms.YM
WHERE (Yms.YM Between format([Start Date],"yymm") And
format([End Date],"yymm"))
ORDER BY Rpt.[Record No];

I hope this works -- I couldn't test it

rather than using query parameters, it would be better to
make a form to collect the dates

ie:
formname --> ReportMenu

textbox controls:
Name --> Date1
Name --> Date2

command button:

Name --> cmdOpenReportLog
OnClick --> [Event Procedure]
'~~~~~~~~~~~~~~~~~
if isnull(me.Date1) then
msgbox "You must specify a beginning date",,"Note"
exit sub
end if
if isnull(me.Date2) then
msgbox "You must specify an end date",,"Note"
exit sub
end if

DoCmd.OpenReport "ReportLog_reportname", _
acPreview,, _
"YMs.YM >= " & format(me.Date1,"yymm") _
& " And YMs.YM <= " & format(me.Date2,"yymm")

'~~~~~~~~~~~~~~~~~

substriture you actual report name for ReportLog_reportname

for the recordsource of the report,
Make the report show everything (change qReportLogSource to
have no criteria) -- use the OpenReport action as shown
above to limit the report as needed

Once you have this working as you need it, post back and we
can help you further with formatting to display months as
you like

btw, don't use spaces in field or tablenames anymore -- once
you start coding, you will appreciate this ;)

FYI, if you want to know how to make your query to use the
form dates:

WHERE (Yms.YM Between format(forms!ReportMenu!Date1,"yymm")
And format(forms!ReportMenu!Date2,"yymm"))


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Hi Crystal,

I think this is what you want (and my thanks for explaining where to find it).
I'm not an Access professional and struggle with a lot of the simple stuff
although things got a lot easier when I found this website.

Look forward to your response.
Best regards
Alison

SELECT [Report Log].[Record No], [Report Log].[Date Reported], [Report Log].
Originator, [Report Log].Area, [Report Log].[Report Type], [Report Log].
Equipment, [Report Log].[Report Details], [Report Log].Status
FROM [Report Log]
WHERE ((([Report Log].[Date Reported]) Between [Start Date] And [End Date]))
ORDER BY [Report Log].[Record No];

Hi Alison,

please post the SQL for your query
from the menu: View, SQL
Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

Hi there,

[quoted text clipped - 16 lines]
Thanks
Alison
 
Many thanks Crystal,
I think I understand what you've said and I'll give it a shot tomorrow (it's
now 00:20 UK time and my brain's not smart enough right now to try tonight).
I'll let you know how I get on.
Have a good day
Alison :)

Hi Alison,

you're welcome :)

Make a table:

*YMs*
YM, text, 4

then, create records for (ie:)
0601
0602
0603
etc

where the first 2 characters are year and the second 2
characters are month.

Now, make a query to "add a YM field to your table" so you
can use that to link:

Name --> qReportLogYM
SQL --> SELECT *, format([Date Reported],"yymm") FROM
[Report Log];

Now, make another query on top of that to get what you want:

Name --> qReportLogSource
SELECT Yms.YM, Rpt.[Record No], Rpt.[Date Reported],
Rpt.Originator, Rpt.Area, Rpt.[Report Type], Rpt.
Equipment, Rpt.[Report Details], Rpt.Status
FROM qReportLogYM as Rpt RIGHT JOIN YMs ON Rpt.YM=Yms.YM
WHERE (Yms.YM Between format([Start Date],"yymm") And
format([End Date],"yymm"))
ORDER BY Rpt.[Record No];

I hope this works -- I couldn't test it

rather than using query parameters, it would be better to
make a form to collect the dates

ie:
formname --> ReportMenu

textbox controls:
Name --> Date1
Name --> Date2

command button:

Name --> cmdOpenReportLog
OnClick --> [Event Procedure]
'~~~~~~~~~~~~~~~~~
if isnull(me.Date1) then
msgbox "You must specify a beginning date",,"Note"
exit sub
end if
if isnull(me.Date2) then
msgbox "You must specify an end date",,"Note"
exit sub
end if

DoCmd.OpenReport "ReportLog_reportname", _
acPreview,, _
"YMs.YM >= " & format(me.Date1,"yymm") _
& " And YMs.YM <= " & format(me.Date2,"yymm")

'~~~~~~~~~~~~~~~~~

substriture you actual report name for ReportLog_reportname

for the recordsource of the report,
Make the report show everything (change qReportLogSource to
have no criteria) -- use the OpenReport action as shown
above to limit the report as needed

Once you have this working as you need it, post back and we
can help you further with formatting to display months as
you like

btw, don't use spaces in field or tablenames anymore -- once
you start coding, you will appreciate this ;)

FYI, if you want to know how to make your query to use the
form dates:

WHERE (Yms.YM Between format(forms!ReportMenu!Date1,"yymm")
And format(forms!ReportMenu!Date2,"yymm"))

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Hi Crystal,
[quoted text clipped - 37 lines]
 
you're welcome, Alison -- good luck!

We are here if you have troubles

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Many thanks Crystal,
I think I understand what you've said and I'll give it a shot tomorrow (it's
now 00:20 UK time and my brain's not smart enough right now to try tonight).
I'll let you know how I get on.
Have a good day
Alison :)

Hi Alison,

you're welcome :)

Make a table:

*YMs*
YM, text, 4

then, create records for (ie:)
0601
0602
0603
etc

where the first 2 characters are year and the second 2
characters are month.

Now, make a query to "add a YM field to your table" so you
can use that to link:

Name --> qReportLogYM
SQL --> SELECT *, format([Date Reported],"yymm") FROM
[Report Log];

Now, make another query on top of that to get what you want:

Name --> qReportLogSource
SELECT Yms.YM, Rpt.[Record No], Rpt.[Date Reported],
Rpt.Originator, Rpt.Area, Rpt.[Report Type], Rpt.
Equipment, Rpt.[Report Details], Rpt.Status
FROM qReportLogYM as Rpt RIGHT JOIN YMs ON Rpt.YM=Yms.YM
WHERE (Yms.YM Between format([Start Date],"yymm") And
format([End Date],"yymm"))
ORDER BY Rpt.[Record No];

I hope this works -- I couldn't test it

rather than using query parameters, it would be better to
make a form to collect the dates

ie:
formname --> ReportMenu

textbox controls:
Name --> Date1
Name --> Date2

command button:

Name --> cmdOpenReportLog
OnClick --> [Event Procedure]
'~~~~~~~~~~~~~~~~~
if isnull(me.Date1) then
msgbox "You must specify a beginning date",,"Note"
exit sub
end if
if isnull(me.Date2) then
msgbox "You must specify an end date",,"Note"
exit sub
end if

DoCmd.OpenReport "ReportLog_reportname", _
acPreview,, _
"YMs.YM >= " & format(me.Date1,"yymm") _
& " And YMs.YM <= " & format(me.Date2,"yymm")

'~~~~~~~~~~~~~~~~~

substriture you actual report name for ReportLog_reportname

for the recordsource of the report,
Make the report show everything (change qReportLogSource to
have no criteria) -- use the OpenReport action as shown
above to limit the report as needed

Once you have this working as you need it, post back and we
can help you further with formatting to display months as
you like

btw, don't use spaces in field or tablenames anymore -- once
you start coding, you will appreciate this ;)

FYI, if you want to know how to make your query to use the
form dates:

WHERE (Yms.YM Between format(forms!ReportMenu!Date1,"yymm")
And format(forms!ReportMenu!Date2,"yymm"))

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

Hi Crystal,

[quoted text clipped - 37 lines]
Thanks
Alison
 
Hi Crystal,

Well everything went fine for a while. I set up the 'YMs' table and the
first query which runs beautifully.
However, I then copied the SQL for the second query.

Name --> qReportLogSource
SELECT Yms.YM, Rpt.[Record No], Rpt.[Date Reported],
Rpt.Originator, Rpt.Area, Rpt.[Report Type], Rpt.
Equipment, Rpt.[Report Details], Rpt.Status
FROM qReportLogYM as Rpt RIGHT JOIN YMs ON Rpt.YM=Yms.YM
WHERE (Yms.YM Between format([Start Date],"yymm") And
format([End Date],"yymm"))
ORDER BY Rpt.[Record No];

Access took it and I have named it as you suggest but everytime I try to run
it I get a message pop-up that 'Microsoft Access has encountered a problem
and needs to close'. I have reported the error and then installed the
suggested updates but I still can't get run the query without Access falling
over.
All other query and reports are running with no problem - it's just this one
qReportLogSource.

Hope you can help
Best regards
Alison

Many thanks Crystal,
I think I understand what you've said and I'll give it a shot tomorrow (it's
now 00:20 UK time and my brain's not smart enough right now to try tonight).
I'll let you know how I get on.
Have a good day
Alison :)
Hi Alison,
[quoted text clipped - 102 lines]
 
Hi Alison,

since you are going to keep the parameters in your query,
tell Access what the data type is...

from the menu of the query design:

Query, Parameters...

[Start Date], date/time
[End Date], date/time

the SQL statement will be modified to:

PARAMETERS [Start Date] DateTime, [End Date] DateTime;
SELECT ...

Instead of collecting a date, you could, for instance, do this:

WHERE (Yms.YM Between [Start YYMM] And [End YYMM])

where you would enter 0601 or 0602 or whatever

the data type for these parameters would be text

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Hi Crystal,

Well everything went fine for a while. I set up the 'YMs' table and the
first query which runs beautifully.
However, I then copied the SQL for the second query.

Name --> qReportLogSource
SELECT Yms.YM, Rpt.[Record No], Rpt.[Date Reported],
Rpt.Originator, Rpt.Area, Rpt.[Report Type], Rpt.
Equipment, Rpt.[Report Details], Rpt.Status
FROM qReportLogYM as Rpt RIGHT JOIN YMs ON Rpt.YM=Yms.YM
WHERE (Yms.YM Between format([Start Date],"yymm") And
format([End Date],"yymm"))
ORDER BY Rpt.[Record No];

Access took it and I have named it as you suggest but everytime I try to run
it I get a message pop-up that 'Microsoft Access has encountered a problem
and needs to close'. I have reported the error and then installed the
suggested updates but I still can't get run the query without Access falling
over.
All other query and reports are running with no problem - it's just this one
qReportLogSource.

Hope you can help
Best regards
Alison

Many thanks Crystal,
I think I understand what you've said and I'll give it a shot tomorrow (it's
now 00:20 UK time and my brain's not smart enough right now to try tonight).
I'll let you know how I get on.
Have a good day
Alison :)

Hi Alison,

[quoted text clipped - 102 lines]
Thanks
Alison
 
Hi Crystal,

Oooooh! I love the parameter bit - I didn't know that one so that's
something I've learnt. Thanks for that.
I've now got a new query running beautifully - I'll try putting it into a
report and let you know how I get on. I'm away now till Wednesday and don't
know whether I'll have time to do anything till I get back but I'll let you
know the outcome later in the week.

Thanks a million for your assistance. I really appreciate the time and
effort you people put in to helping us amateurs.

Best Regards
Alison
 
you're welcome, Alison ;) happy to help


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Hi Crystal,

Well ..... the query runs beatifully as I said, but when I run a report based
on that query I still don't get a header or a zero return for the areas which
have no data.
Do I need to change something in the report or group header properties to
collect this data?

Best regards
Alison
 
Hi Alison,

If the report doesn't show data ... are you sure that the
query does?

click on the builder button in the Recordset property of the
report (...) -- see if the headers you want to show with no
data actually do show in the recordset -- my guess is that
they don't...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Hi Crystal,

You are quite right; the query does not show the records, although I was not
expecting it to. I guess I was expecting to just see the header and the zero
count in the report - duh!
Sorry to be such a dummy but can you tell me where to find the Recordset
properties for the report. I can't find anything called 'recordset' anywhere
in the report properties (so I figure I'm looking in the wrong place!)

Regards
Alison

Hi Alison,

If the report doesn't show data ... are you sure that the
query does?

click on the builder button in the Recordset property of the
report (...) -- see if the headers you want to show with no
data actually do show in the recordset -- my guess is that
they don't...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Hi Crystal,
[quoted text clipped - 21 lines]
 
Hi Alison,

for more info on the Recordset Property, see below...

~~~~ Properties and Methods ~~~~

Just like in the real world, every object has properties and
methods.

Properties are like adjectives that describe an object
Methods are like verbs and define actions an object can do

For instance, you are a human and have properties such as
hair color, eye color, height, weight, ... and methods such
as eat, walk, run, jump, ... make babies -- Add to a
collection :)

In the design view, you can show the property sheet, which
will show information for the selected item(s).

~~~~ turn on Properties window ~~~~

When you are in the design view, turn on/off the Properties
window -->

1. from menu: View, Properties
OR
2. right-click and choose Properties from the shortcut menu

and then click on various objects. The properties window
changes as you change what is selected. If you have
multiple objects selected, the values for the properties
they have in common will be displayed

Try it!

~~~~ setting Properties vs. resizing with handles ~~~~

I like to make the width of controls exact -- like 0.25,
0.3, 0.4, 0.5, 0.6, 0.75, 1, 1.25, etc

This is especially handing for lining up labels to controls
under them

~~~~ selecting objects ~~~~

you can select multiple controls
1. click and drag the mouse and everything your imaginary
rectangle touches before you let go will be selected
OR
2. click, shift-click, etc
shift-click actually toggles the select status without
affecting the other items selected
OR
3. click (optionally, and drag) in a ruler
while the mouse is down, you will see a line extend across
(vertical ruler) or down (horizontal ruler)
if you click and drag, the ruler will turn dark indicating
where you started and stopped
-- everything the line/rectangle touches will be selected
OR
4. drop down the objects combo (left-most control on design
toolbar) and select something by its name

~~~~ select Form or Report ~~~~

To select the form (or report), you may:

1. click in the upper left corner where the rulers intersect
OR
2. click completely outside the designed area in the dark
gray space
OR
3. press CTRL-R
OR
4. from menu: Edit, Select Form/Report

~~~~ building event code ~~~

To build an event, click in the property sheet for the
appropriate object in the appropriate location and then
click the builder (...) button off to the right

Access will provide the procedure declaration and the
procedure end -- you put the lines in between.

~~~~ Name property ~~~~

Procedures are NAMED according to the object name (except
the form object), so ALWAYS change the NAME property of any
object to something logical.

When the properties window is displayed and only one thing
is selected, the Name appears in the title bar of the
Properties window

If multiple items are selected, you will see "Multiple
Selection" on the title bar

~~~~ ControlSource, SourceObject ~~~~

It is important to realize that the Name is NOT what is
displayed in a control. If the control is (for instance a
textbox or combo box), you will see the ControlSource displayed.

If the object is (for instance) a subform or subreport, what
you see displayed is the SourceObject

For bound objects, I like to make the Name property match
the source property (this does not, btw, follow naming
conventions, but for me, it eases confusion)

As always, avoid using spaces and special characters when
naming objects -- use the underscore character _ to separate
and use mixed case for readability

~~~~ Recordset Property ~~~~

from the design view of a report or form:

turn on Properties
(from menu: View, Properties)

select the report or form
(click in the upper left where the rulers intersect)

click on the Data tab in Properties window

there you will see the RecordSet property
once you click in the property, you will see the builder
button ... to the right

If your report is based on a query, this takes you to the
query design screen

If your report is based on a SQL statement, you can modify
it like the design view of a query (you can also press
SHIFT-F2 to use the Zoom Box to change the SQL)

If your report is based on a table, you will be asked if you
want to make a query

~~~~ Builder Button ~~~~

The RowSource property for a combo or list box is like the
RecordSource property for a form or report -- you are
choosing where the data will come from that is displayed.
The Builder Button ... will be displayed when you click IN
the property.

For choosing colors that are not on the color palette (like
ForeColor, BackColor, Bordercolor), click the builder
button. Once in the palette dialog box, click "Define
Custom Colors" -- the dialog box will expand and you can set
the amounts for Red/Green/Blue or adjust
Hue/Saturation/Luminosity. There is also a slider control
with a triangle you can drag up or down to change the
Luminosity (brightness). I like to drag it up and fade out
colors, especially for BackColor.

~~~~ Events ~~~~

"Properties" listed on the Events tab are actually methods
.... such as OnCurrent for form, AfterUpdate for Control, etc

~~~~ Learning the properties ~~~~

Explore the property sheet. Get familiar with how
properties are grouped on the tabs and the different
properties for different objects.

~~~~ Help on Properties ~~~~

You can get help about any property by pressing F1 while in
the property you want more information on.

~~~~ general help ~~~~

For general help about Access, I find it interesting and
informative to read the help starting from the beginning of
the Contents. In fact, if you have the desire to print a
ream of paper, it would be good to print it like a book and
read it so you can also take notes -- and you can read it
away from the computer -- a good time to put new information
into your head is just before you sleep ... let your
subconscious figure it out!


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
Hi Crystal,

You are quite right; the query does not show the records, although I was not
expecting it to. I guess I was expecting to just see the header and the zero
count in the report - duh!
Sorry to be such a dummy but can you tell me where to find the Recordset
properties for the report. I can't find anything called 'recordset' anywhere
in the report properties (so I figure I'm looking in the wrong place!)

Regards
Alison

Hi Alison,

If the report doesn't show data ... are you sure that the
query does?

click on the builder button in the Recordset property of the
report (...) -- see if the headers you want to show with no
data actually do show in the recordset -- my guess is that
they don't...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

Hi Crystal,

[quoted text clipped - 21 lines]
Best Regards
Alison
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top