access report

B

bridgeman

any one know how I can get data to display in columnar form by date? I am
working in access.
Like if I have the week of:

10/21/09 10/22/09 10/23/09 10/24/09
10/25/09
crew no 1 work order work order work order work order
work order
crew no 2 wrok order work order work order work order
work order

I have 14 crews so the list would continue. I can't get the report to
complie the data correctly.
Any suggestions?
Bridgeman
 
J

Jeff Boyce

Take a look at Access HELP for "crosstab" ... start out using a crosstab
query to make sure you're getting the data as expected...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
B

bridgeman

Well, that was interesting. I managed to set up the cross tab query and it
returns the requested info, however I don't know where to go from here. I
have toiled with this for months now. I dont think the problem is getting the
data in a query, the problem seems to be getting the data to display on the
form in the format that I need it.

For instance, Lets say that one of my crews submits their schedule for the
week of 10/19 through 10/23.

The form I created in Infopath for them contains a separate text box for the
crew name, then I created a separate repeating section on the from that
contains the following fields. Date (datepicker), work order number (which
they choose from a list, and that is it. They then can create a new section
on the form as needed for additional dates and work orders. Once that is
submitted it hits a table in access with the same fields, and a query starts
that is joined at the work order number to another table containing the
location and specific instructions for that work order. Now at any given time
I have 14 crews working 5 days with a constant flow of work orders ranging
from 300-350.
The display needed on the form should be something to the effect of:

10/21/09 10/22/09 10/23/09 10/24/09

crew no 1 work order work order work order work order
Location/etc Location/etc Location/etc
Location/etc

work order
Location/etc

Crew no 2 work order work order work order work order

Now a crew may or may not work several work orders in one day and that info
needs to display as well. I have gotten the from to display the info
vertically as opposed to horizontally by date like this:

10/22/09
Crew: 1 work order
location/etc

Crew: 2 10/23/09
work order
location/etc

Thanks,
I hope this helps
Bridgeman
 
J

Jeff Boyce

No experience working InfoPath into Access, so perhaps another newsgroup
reader can offer ideas.

How depends on what -- what do you want to do? Do you want the information
to display on a screen? Use the crosstab query to 'feed' a form.

Do you want a printed report? Use the crosstab query to 'feed' your report.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
B

bridgeman

The infopath side is working fine and has no bearing on the access end in
this case.
Well first let me thank you for your help and then let me tell you that it
has worked.
The crosstab query works and the the only problem now is that all the data
is displaying vertically. When I created the report from the crosstab query
the data is still showing up vertically under one date even thought there are
different dates. The query is calculating the totals of the rows for the
number of work orders for each crew on a specific date.
 
B

bridgeman

Well Ken,
Thank you very much. I am a very novice user but I am attempting to use the
code structure that you have provided as a reference, not quite sure how far
I will get. I have always been impressed with people like you who can do
this. It seems as though you write this stuff in your sleep.
I think this may be beyond my capabilities but I wont quit. I came into my
current position with lofty goals of getting out of the archaic way of doing
things and have met resistance at all levels so I am winging it. Our IT dept.
can barely maintain what we have due to its age let alone devote any time to
helping out here.
So I guess I will keep plugging away at it and see what I can make work.
I thank you so much for your help. Believe me every bit is appreciated
Cheers,
Bridgeman

KenSheridan via AccessMonster.com said:
I wouldn’t use a cross tab query for this at all. I'd suggest using a form
with five subforms for the form, and a report with five subreports for the
report. I'll describe it for the report, but the form/subforms would be
similar. I'm assuming the report is for one week's data only.

Firstly to select the week in question create an unbound dialogue form,
frmWeeklyReport say, with a control, txtWeekStart say, in which to enter the
date of the Monday on which the week starts, and a button which opens the
report.

If you want the week selected to always be Monday to Friday, in the
BeforeUpdate event procedure of the txtWeekStart control put:

Const MESSAGETEXT = "Date must be a Monday."
Dim ctrl as Control

Set ctrl = Me.ActiveControl

If Not IsNull(ctrl) Then
If WeekDay(CDate(ctrl)) <> vbMonday Then
MsgBox MESSAGETEXT, vbExclamation, "Invalid date"
Cancel = True
End If
End If

This will force the user to enter a Monday date. Otherwise any date on any
day of the week can be entered and the 5 days from then will be returned.

For the report's RecordSource you'll need a query which returns the Crews as
distinct values and the dates for each day of the week. I'll assume
everything is in one table called WorkLog, so the query would be like this:

PARAMETERS
Forms!frmWeeklyReport!txtWeekStart DATETIME;
SELECT DISTINCT [Crew],
Forms!frmWeeklyReport!txtWeekStart As Day1,
DATEADD("d",1, Forms!frmWeeklyReport!txtWeekStart) As Day2,
DATEADD("d",2, Forms!frmWeeklyReport!txtWeekStart) As Day3,
DATEADD("d",3, Forms!frmWeeklyReport!txtWeekStart) As Day4,
DATEADD("d",4, Forms!frmWeeklyReport!txtWeekStart) As Day5
FROM [WorkLog]
ORDER BY [Crew];

Create a report based on this query and layout the bound controls in the page
header so the Day1 is indented:

………………..Day1…….Day2…….Day3…….Day4…….Day5

and in the detail section put the control bound to the Crew field on the left:


Crew

Sort the report by Crew in the Sorting and Grouping dialogue in report design
view.

Next create the 5 subreports. They'll all be the same but with different
RecordSource properties so you can design the first then copy, rename and
change its RecordsSource for each of the others. Layout the subreport with
the work order, location etc controls above each other in a narrow format.
Do not include the crew or workdate. The query for the first subreport's
RecordSource will be like this:

PARAMETERS
Forms!frmWeeklyReport!txtWeekStart DATETIME;
SELECT [Crew], [Work Order], [Location], <etc>
FROM [WorkLog]
WHERE [Workdate] =
Forms!frmWeeklyReport!txtWeekStart;

The query for the second report's RecordSource will be:

PARAMETERS
Forms!frmWeeklyReport!txtWeekStart DATETIME;
SELECT [Crew], [Work Order], [Location],, <etc>
FROM [WorkLog]
WHERE [Workdate] =
DATEADD("d",1, Forms!frmWeeklyReport!txtWeekStart);

and so on until the fifth subreport. Sort each subreport by Work Order.

In the main report place the first subreport in the detail section alongside
the Crew control and under the Day1 control, the second under the Day2
control and so on.

Link each subreport to the main report by setting its LinkMasterFields and
LinkChildFields properties to Crew (change the field names here and in the
above to your real ones as appropriate).

Make sure that that the main report's detail section, and those of each
subreport have their CanGrow property set to True (Yes in the properties
sheet), the subform controls in the main report have their CanGrow property
set to True, and that any controls in the subforms which need to grow
vertically also have their CanGrow property set to True. Also set the main
report's details section's KeepTogether property to True.

When you open the report from the dialogue form you should get each crew
listed in order, with alongside, their work for each day of the week in
question under each date in the page header.

Ken Sheridan
Stafford, England
The infopath side is working fine and has no bearing on the access end in
this case.
Well first let me thank you for your help and then let me tell you that it
has worked.
The crosstab query works and the the only problem now is that all the data
is displaying vertically. When I created the report from the crosstab query
the data is still showing up vertically under one date even thought there are
different dates. The query is calculating the totals of the rows for the
number of work orders for each crew on a specific date.
No experience working InfoPath into Access, so perhaps another newsgroup
reader can offer ideas.
[quoted text clipped - 93 lines]

--



.
 
B

bridgeman

Ken,

I have gotten it together but am running into an error that I believe is
from the parameters to the query While in design view I attempt to run the
query and a message comes up about bracketing "invalid bracketing of name
"[Forms!frmWeeklyreport!txtWeekStart DATETIME;], I have removed the brackets
but the message still comes up .I have just built a separate database to use
your recommendations. I have followed it exactly but to no avail.

Thank You in advance

KenSheridan via AccessMonster.com said:
Not quite in my sleep perhaps, but it is a question of experience more than
anything. We were all novices once, remember. I'm sure you can crack it if
you take it step by step, but post back as and when you need any help.

Good luck,

Ken Sheridan
Stafford, England
Well Ken,
Thank you very much. I am a very novice user but I am attempting to use the
code structure that you have provided as a reference, not quite sure how far
I will get. I have always been impressed with people like you who can do
this. It seems as though you write this stuff in your sleep.
I think this may be beyond my capabilities but I wont quit. I came into my
current position with lofty goals of getting out of the archaic way of doing
things and have met resistance at all levels so I am winging it. Our IT dept.
can barely maintain what we have due to its age let alone devote any time to
helping out here.
So I guess I will keep plugging away at it and see what I can make work.
I thank you so much for your help. Believe me every bit is appreciated
Cheers,
Bridgeman
I wouldn’t use a cross tab query for this at all. I'd suggest using a form
with five subforms for the form, and a report with five subreports for the
[quoted text clipped - 113 lines]
 
B

bridgeman

Below is the SQL version. I see that there are some double brackets in there
and I am not sure if that is what you are referring to. When I entered the
parameters I put them in from the query design view not in the SQL view.

PARAMETERS [[frmWeeklyReport]![txtWeekStart DATETIME;]] Text ( 255 ),
[SELECT DISTINCT [CREW],] Text ( 255 ),
[[Forms]!frmWeeklyReport![txtWeekStart as Day1,]] Text ( 255 ),
[[DATEADD("D",1, Forms]!frmWeeklyReport![txtWeekStart) As Day2,]] Text ( 255
), [[DATEADD("D",2, Forms]!frmWeeklyReport![txtWeekStart) As Day3,]] Text (
255 ), [[DATEADD("D",3, Forms]!frmWeeklyReport![txtWeekStart) As Day4,]] Text
( 255 ), [[DATEADD("D",4, Forms]!frmWeeklyReport![txtWeekStart) As Day5,]]
Text ( 255 ), [[DATEADD("D",5, Forms]!frmWeeklyReport![txtWeekStart) As
Day6,]] Text ( 255 ), [[DATEADD("D",6, Forms]!frmWeeklyReport![txtWeekStart)
As Day7,]] Text ( 255 ), [From [workLog]] Text ( 255 ), [order by [crew];]
Text ( 255 );
SELECT WorkLog.Crew, WorkLog.Datex, WorkLog.[Work instructions],
WorkLog.[bridge no], WorkLog.[site no]
FROM WorkLog;

Thank
Bridgeman
KenSheridan via AccessMonster.com said:
The Individual objects should be bracketed, not the parameter declaration as
a whole, i.e.

[Forms]![frmWeeklyreport]![txtWeekStart] DATETIME;

If you switch to SQL view the query should start:

[Forms]![frmWeeklyreport]![txtWeekStart] DATETIME;
SELECT…….

i.e. the PARAMETERS clause comes before the query as you'd normally see it
and is terminated by a semi-colon.

The DATETIME may be in mixed case if the query has been built in design view,
but its case insensitive, so either will do. I use upper case because a
common convention when writing SQL is to use upper case for SQL keywords,
function names etc, and lower or mixed case for table and column names. In
SQL view the brackets aren't in fact necessary unless an object name includes
a space or a special character, which isn't the case here. But if in doubt
include the brackets regardless.

If you still have problems post back with the SQL of the query(ies).

Ken Sheridan
Stafford, England
Ken,

I have gotten it together but am running into an error that I believe is
from the parameters to the query While in design view I attempt to run the
query and a message comes up about bracketing "invalid bracketing of name
"[Forms!frmWeeklyreport!txtWeekStart DATETIME;], I have removed the brackets
but the message still comes up .I have just built a separate database to use
your recommendations. I have followed it exactly but to no avail.

Thank You in advance
Not quite in my sleep perhaps, but it is a question of experience more than
anything. We were all novices once, remember. I'm sure you can crack it if
[quoted text clipped - 25 lines]

--



.
 
B

bridgeman

wait a minute, disregard the last. I believe I just got it to run the query.

KenSheridan via AccessMonster.com said:
The Individual objects should be bracketed, not the parameter declaration as
a whole, i.e.

[Forms]![frmWeeklyreport]![txtWeekStart] DATETIME;

If you switch to SQL view the query should start:

[Forms]![frmWeeklyreport]![txtWeekStart] DATETIME;
SELECT…….

i.e. the PARAMETERS clause comes before the query as you'd normally see it
and is terminated by a semi-colon.

The DATETIME may be in mixed case if the query has been built in design view,
but its case insensitive, so either will do. I use upper case because a
common convention when writing SQL is to use upper case for SQL keywords,
function names etc, and lower or mixed case for table and column names. In
SQL view the brackets aren't in fact necessary unless an object name includes
a space or a special character, which isn't the case here. But if in doubt
include the brackets regardless.

If you still have problems post back with the SQL of the query(ies).

Ken Sheridan
Stafford, England
Ken,

I have gotten it together but am running into an error that I believe is
from the parameters to the query While in design view I attempt to run the
query and a message comes up about bracketing "invalid bracketing of name
"[Forms!frmWeeklyreport!txtWeekStart DATETIME;], I have removed the brackets
but the message still comes up .I have just built a separate database to use
your recommendations. I have followed it exactly but to no avail.

Thank You in advance
Not quite in my sleep perhaps, but it is a question of experience more than
anything. We were all novices once, remember. I'm sure you can crack it if
[quoted text clipped - 25 lines]

--



.
 
B

bridgeman

ok that portion is working. I added code to reflect a 7 day work week. That
works. I have built 7 sub queries for each subsequent day. That appears to be
working. I have the main report running of the query for the date column
heading and that works. I am working on the reports sub-reports now. I think
this is going to work. I am still figuring out the subreport portion. I
understand the concept where under each day of the week a sub report will
display the other info as it relates to the day and the crew. I put one in
for the first day just to test it and about 3 dialogue boxes pop up in a row.
My response to each one is to put in the date, Then it shows the report with
the subreport for that day. Should it require me to enter the date that many
times?
Thanks
Bridgeman

KenSheridan via AccessMonster.com said:
The Individual objects should be bracketed, not the parameter declaration as
a whole, i.e.

[Forms]![frmWeeklyreport]![txtWeekStart] DATETIME;

If you switch to SQL view the query should start:

[Forms]![frmWeeklyreport]![txtWeekStart] DATETIME;
SELECT…….

i.e. the PARAMETERS clause comes before the query as you'd normally see it
and is terminated by a semi-colon.

The DATETIME may be in mixed case if the query has been built in design view,
but its case insensitive, so either will do. I use upper case because a
common convention when writing SQL is to use upper case for SQL keywords,
function names etc, and lower or mixed case for table and column names. In
SQL view the brackets aren't in fact necessary unless an object name includes
a space or a special character, which isn't the case here. But if in doubt
include the brackets regardless.

If you still have problems post back with the SQL of the query(ies).

Ken Sheridan
Stafford, England
Ken,

I have gotten it together but am running into an error that I believe is
from the parameters to the query While in design view I attempt to run the
query and a message comes up about bracketing "invalid bracketing of name
"[Forms!frmWeeklyreport!txtWeekStart DATETIME;], I have removed the brackets
but the message still comes up .I have just built a separate database to use
your recommendations. I have followed it exactly but to no avail.

Thank You in advance
Not quite in my sleep perhaps, but it is a question of experience more than
anything. We were all novices once, remember. I'm sure you can crack it if
[quoted text clipped - 25 lines]

--



.
 
B

bridgeman

Well Ken we are almost there. What a long strange trip its been. I have
redone the entire db to conform to my needs. Everything is working as
expected. I am still having a bit of trouble with the sub-reports on the main
report. I expect it is just a matter of trial and error until it works. I
have adjusted some of the vba to fit my structure and it is working. I am
still confused regarding the sub forms (are they needed? and are they
different from the sub-reports?). I can see what we are attempting to do with
the sub report on the main report, and I am just trying to get everything
lined up to display correctly. The fields are all appearing when I view the
report in report view but the fields are not populated with data in the
query. I placed the first sub report on the main just to get a feel for it. I
will let you know.
For what it is worth I appreciate your time,
Bridgeman

KenSheridan via AccessMonster.com said:
No, you only have to enter the date once, in the txtWeekStart control in the
dialogue form. The report is opened from that form and each of the queries
(1 for the main report and one for each subreport) references that control as
a parameter. To test the queries independently open the dialogue form first
and enter a date, making sure you press Enter after typing it into the
control; then open the query while the dialogue form is still open.

Ken Sheridan
Stafford, England
ok that portion is working. I added code to reflect a 7 day work week. That
works. I have built 7 sub queries for each subsequent day. That appears to be
working. I have the main report running of the query for the date column
heading and that works. I am working on the reports sub-reports now. I think
this is going to work. I am still figuring out the subreport portion. I
understand the concept where under each day of the week a sub report will
display the other info as it relates to the day and the crew. I put one in
for the first day just to test it and about 3 dialogue boxes pop up in a row.
My response to each one is to put in the date, Then it shows the report with
the subreport for that day. Should it require me to enter the date that many
times?
Thanks
Bridgeman
The Individual objects should be bracketed, not the parameter declaration as
a whole, i.e.
[quoted text clipped - 38 lines]

--



.
 
B

bridgeman

okay, I have the subreports all in place on the main report. Still confused
about how the sub forms relate to the main forms (frmWeeklyReport). But the
command button that I placed on the form next to the text box for the date
entry(which by the way works) does not respond. I attached it to my main form
and is set to open my main report, but nothing happens when I click it. I
used the command wizard to create it.
Thanks again,

KenSheridan via AccessMonster.com said:
No, you only have to enter the date once, in the txtWeekStart control in the
dialogue form. The report is opened from that form and each of the queries
(1 for the main report and one for each subreport) references that control as
a parameter. To test the queries independently open the dialogue form first
and enter a date, making sure you press Enter after typing it into the
control; then open the query while the dialogue form is still open.

Ken Sheridan
Stafford, England
ok that portion is working. I added code to reflect a 7 day work week. That
works. I have built 7 sub queries for each subsequent day. That appears to be
working. I have the main report running of the query for the date column
heading and that works. I am working on the reports sub-reports now. I think
this is going to work. I am still figuring out the subreport portion. I
understand the concept where under each day of the week a sub report will
display the other info as it relates to the day and the crew. I put one in
for the first day just to test it and about 3 dialogue boxes pop up in a row.
My response to each one is to put in the date, Then it shows the report with
the subreport for that day. Should it require me to enter the date that many
times?
Thanks
Bridgeman
The Individual objects should be bracketed, not the parameter declaration as
a whole, i.e.
[quoted text clipped - 38 lines]

--



.
 
B

bridgeman

Thanks Ken,
I feel like I should be paying you for this. But alas, I have read some
posts asking for help where the asker of help has responded in argumentitive
or negative ways. I of course really appreciate the help. I will take a look
at your suggestions and see what I come up with. I will let you know what
happens. I wish I could get all the code out of the db that I have so far and
post it so you could see what it is. Thanks
Cheers,
Bridgeman.

KenSheridan via AccessMonster.com said:
Each subreport's query includes a parameter on the date column which
restricts it to one day's data by referencing the txtWeekStart control on the
form. The first has a parameter of:

Forms!frmWeeklyReport!txtWeekStart

so it is restricted to the date you enter in the form. The second has a
parameter of:

DATEADD("d",1, Forms!frmWeeklyReport!txtWeekStart)

so it is restricted to the date following that you enter in the form.

and so on up to:

DATEADD("d",4, Forms!frmWeeklyReport!txtWeekStart)

The subforms are also restricted to the Crew in the report's current detail
by setting the subreport controls' LinkMasterFields and LinkChildFields
properties to Crew (or whatever the field name is). So for each Crew you
should get alongside, the jobs for each day of the week in the 5 subreports,
each setting out the data vertically in the way you described.

As regards the button, it should have code in its Click event procedure which
opens the report by means of the OpenReport method. If not I'd suggest
deleting the button and creating a new one with the control wizard. The code
it creates should be something like this:

On Error GoTo Err_YourButtonName_Click

Dim stDocName As String

stDocName = "YourReportName"
DoCmd.OpenReport stDocName, acPreview

Exit_YourButtonName_Click:
Exit Sub

Err_YourButtonName_Click:
MsgBox Err.Description
Resume Exit_YourButtonName_Click

Ken Sheridan
Stafford, England
okay, I have the subreports all in place on the main report. Still confused
about how the sub forms relate to the main forms (frmWeeklyReport). But the
command button that I placed on the form next to the text box for the date
entry(which by the way works) does not respond. I attached it to my main form
and is set to open my main report, but nothing happens when I click it. I
used the command wizard to create it.
Thanks again,
No, you only have to enter the date once, in the txtWeekStart control in the
dialogue form. The report is opened from that form and each of the queries
[quoted text clipped - 25 lines]

--



.
 
B

bridgeman

My main report does what it is supposed to do. I created the subforms of
which there are 7 tied their record source to the subquery and then created
the subform and put it on the main form with it s master child relationship
based on the crew name. when I run the dialogue to open the report from the
form by entering the date, and using the open report button the report now
opens thanks to the code you placed in your last response, the report shows
the dates across the top and a heading for crew but nothing comes in. All the
sub queries work and return results. I wish there was a way I could just send
the db to you in the state it is in so you could show me where I am going
wrong. I think I am almost there but this new 2007 access bible that I am
using offers little help to me. So hopefully with a little more time I'll get
it with your help. It is much appreciated by the way.
Thanks
Bridgeman
Jacksonville, FL

KenSheridan via AccessMonster.com said:
Each subreport's query includes a parameter on the date column which
restricts it to one day's data by referencing the txtWeekStart control on the
form. The first has a parameter of:

Forms!frmWeeklyReport!txtWeekStart

so it is restricted to the date you enter in the form. The second has a
parameter of:

DATEADD("d",1, Forms!frmWeeklyReport!txtWeekStart)

so it is restricted to the date following that you enter in the form.

and so on up to:

DATEADD("d",4, Forms!frmWeeklyReport!txtWeekStart)

The subforms are also restricted to the Crew in the report's current detail
by setting the subreport controls' LinkMasterFields and LinkChildFields
properties to Crew (or whatever the field name is). So for each Crew you
should get alongside, the jobs for each day of the week in the 5 subreports,
each setting out the data vertically in the way you described.

As regards the button, it should have code in its Click event procedure which
opens the report by means of the OpenReport method. If not I'd suggest
deleting the button and creating a new one with the control wizard. The code
it creates should be something like this:

On Error GoTo Err_YourButtonName_Click

Dim stDocName As String

stDocName = "YourReportName"
DoCmd.OpenReport stDocName, acPreview

Exit_YourButtonName_Click:
Exit Sub

Err_YourButtonName_Click:
MsgBox Err.Description
Resume Exit_YourButtonName_Click

Ken Sheridan
Stafford, England
okay, I have the subreports all in place on the main report. Still confused
about how the sub forms relate to the main forms (frmWeeklyReport). But the
command button that I placed on the form next to the text box for the date
entry(which by the way works) does not respond. I attached it to my main form
and is set to open my main report, but nothing happens when I click it. I
used the command wizard to create it.
Thanks again,
No, you only have to enter the date once, in the txtWeekStart control in the
dialogue form. The report is opened from that form and each of the queries
[quoted text clipped - 25 lines]

--



.
 

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

Top