Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Reporting different data in the same record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JenISCM - 09 Jan 2008 15:21 GMT
I have a report where I need to report data for the same record in two ways.  

I can have a Contract Signed date and a Cancelled date for the same record.

I need to create a report to compare this data monthly – totaling all the
Contract Signed in that month and all the Cancelled items in that month.  
(These date can occur in the same OR separate months.)  

I also need to be able to run this report for specified time periods.  (Ex:  
Jan – Jun, or just the month of Dec, etc.)

Any assistance would be GREATLY appreciated.
Signature

JenISCM

John W. Vinson - 09 Jan 2008 18:52 GMT
>I have a report where I need to report data for the same record in two ways.  
>
[quoted text clipped - 8 lines]
>
>Any assistance would be GREATLY appreciated.

A criterion of

>= DateSerial([Enter year:], [Enter month number:], 1) AND < DateSerial([Enter year:], [Enter month number:] + 1, 1)

on both the Contract Signed and the Cancelled field's Criteria line will work.
Put the criterion on *two separate rows* in the query grid so that it will use
OR logic.

It's not quite clear what you mean by "totalling" - what are you totalling?

            John W. Vinson [MVP]
JenISCM - 09 Jan 2008 19:12 GMT
That gave me almost the data I need.

It showed me all the Contract Cancel and all the Contract Signed records in
December.  Here is the problem.  The Contract Cancelled items have Contract
Signed dates in months other than December.  Thus those results show in
months other than Dec on my report.

I think I may have a resolution but maybe you could assist on this.

I have created two separate queries - one for Contract Signed and one for
Cancelled with Between paramters.   The only problem and they have to enter
two begin dates and two end dates.

Is there a way to have a SINGLE entry for both queries for the Month Year
like you suggested for both queries.  Or link the between parameter form one
to the other so that the report user on has to make one entry OR - if you
have a better solution.  

Totalling clarification - From the final resulting data I crated cross tab
queries to total counts and amounts for each Signed and Cancelled record.

Signature

JenISCM

> >I have a report where I need to report data for the same record in two ways.  
> >
[quoted text clipped - 20 lines]
>
>              John W. Vinson [MVP]
John W. Vinson - 09 Jan 2008 19:54 GMT
>Is there a way to have a SINGLE entry for both queries for the Month Year
>like you suggested for both queries.  Or link the between parameter form one
>to the other so that the report user on has to make one entry OR - if you
>have a better solution.  

Ken's UNION query suggestion is your best bet. Sorry about misinterpreting the
requirement!

            John W. Vinson [MVP]
Ken Sheridan - 09 Jan 2008 19:15 GMT
As the dates are in separate columns in the table to group them by month
you'll need to get the year and month for each into the same columns in the
query on which the report is based so you can group by them.  You can do this
with a union query, e.g.

SELECT [Contract], [Contract Signed], [Cancelled], [Contact Amount],
YEAR([Contact Signed]) AS TransactionYear,
MONTH([Contact Signed]) AS TransactionMonth
WHERE [Cancelled] IS NULL
UNION ALL
SELECT [Contract], [Contract Signed], [Cancelled], [Contact Amount],
YEAR([Cancelled]), MONTH([Cancelled])
WHERE [Cancelled] IS NOT NULL;

Group the report on TransactionYear and TransactionMonth columns and give
the latter group a group footer.

In the group footer add two text boxes for the two totals.  If by
'totalling' you mean counting the instances of contracts signed and cancelled
per month then for signed contracts you'd use an expression like this for the
ControlSource of the text box:

=Sum(IIf(IsNull([Cancelled]) Or Format([Cancelled],"yyyymm") =
Format([Contract Signed],"yyyymm"), 1, 0))

and for the cancelled contracts:

=Sum(IIf(Not IsNull([Cancelled]), 1, 0))

If by totalling you mean summing some other column, e.g. Contact Amount,
then substitute the name of the column for the 1 constants in the above
expressions.

To open the report for a month or range of months create a dialogue form
with text boxes YearStart, MonthStart and YearEnd and Month end in which the
parameters can be entered as numbers.  Add a button to the form with code to
open the report like this:

Const conREPORT = "YourReportNameGoesHere"
Dim strCtriteria As String
Dim dtmStart as Date, dtmEnd As Date

dtmStart = DateSerial(Me.YearStart, Me.MonthStart, 1)
dtmEnd = DateSerial(Me.YearEnd, Me.MonthEnd + 1, 0)

strCriteria = _
  "[Contract Date] Between #" & _
  "Format(dtmStart,"mm/dd/yyyy") & "# And " & _
  "Format(dtmEnd,"mm/dd/yyyy") & "# Or " & _
  "[Cancelled] Between #" & _
  "Format(dtmStart,"mm/dd/yyyy") & "# And " & _
  "Format(dtmEnd,"mm/dd/yyyy") & "#"

DoCmd.OpenReporst conREPORT, _
   View:=acViewPreview, _
   WhereCondition:=strCriteria

Ken Sheridan
Stafford, England

> I have a report where I need to report data for the same record in two ways.  
>
[quoted text clipped - 8 lines]
>
> Any assistance would be GREATLY appreciated.
Ken Sheridan - 09 Jan 2008 22:19 GMT
DoCmd.OpenReporst??

Should have been DoCmd.OpenReport of course!

KWS
JenISCM - 10 Jan 2008 19:21 GMT
I am just an intermediate Access user with little SQL knowledge, but the
UNION query sounds like the answer to numerous issues I have with trying to
filter based on varied dates, so I tried to recreate using my data (note:  I
have multiple tables so I specified the from)

SELECT [CONTRACTSIGNED], [CONTRACTCX]
FROM [CCLIENT]
YEAR ([CONTRACTSIGNED]) AS TransactionYear
MONTH ([CONTRACTSIGNED]) AS TrasnactionMonth
WHERE [CONTRACTCX] IS NULL
UNION ALL
SELECT [CONTRACTSIGNED], [CONTRACTCX]
FROM [CCLIENT]
Year ([CONTRACTCX]), MONTH ([CONTRACTCX])
WHERE [CONTRACTCX] IS NOT NULL;

I keep getting a syntax error - what is wrong with my formula???

OR I tried:

And I get a syntax error that formua  contains a reserved word:
SELECT [CONTRACTSIGNED], [CONTRACTCX],
YEAR ([CONTRACTSIGNED]) AS TransactionYear
MONTH ([CONTRACTSIGNED]) AS TrasnactionMonth
WHERE [CONTRACTCX] IS NULL
UNION ALL
SELECT [CONTRACTSIGNED], [CONTRACTCX]
Year ([CONTRACTCX]), MONTH ([CONTRACTCX])
WHERE [CONTRACTCX] IS NOT NULL;

HELP!!!

Signature

JenISCM

> As the dates are in separate columns in the table to group them by month
> you'll need to get the year and month for each into the same columns in the
[quoted text clipped - 68 lines]
> >
> > Any assistance would be GREATLY appreciated.
Douglas J. Steele - 10 Jan 2008 19:48 GMT
Your function calls need to go before the FROM keyword:

SELECT [CONTRACTSIGNED], [CONTRACTCX],
YEAR ([CONTRACTSIGNED]) AS TransactionYear
MONTH ([CONTRACTSIGNED]) AS TrasnactionMonth
FROM [CCLIENT]
WHERE [CONTRACTCX] IS NULL
UNION ALL
SELECT [CONTRACTSIGNED], [CONTRACTCX],
Year ([CONTRACTCX]), MONTH ([CONTRACTCX])
FROM [CCLIENT]
WHERE [CONTRACTCX] IS NOT NULL;

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I am just an intermediate Access user with little SQL knowledge, but the
> UNION query sounds like the answer to numerous issues I have with trying
[quoted text clipped - 113 lines]
>> >
>> > Any assistance would be GREATLY appreciated.
JenISCM - 10 Jan 2008 20:25 GMT
I copied exactly and still get this error:
"The Select statement includes a reserved word or an argument that is
misspelled or missing, or the punctuation is incorrect."
Signature

JenISCM

> Your function calls need to go before the FROM keyword:
>
[quoted text clipped - 126 lines]
> >> >
> >> > Any assistance would be GREATLY appreciated.
Douglas J. Steele - 10 Jan 2008 20:39 GMT
Sorry, I didn't notice there was no comma after TransactionYear (the perils
of copy-and-paste!)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I copied exactly and still get this error:
> "The Select statement includes a reserved word or an argument that is
[quoted text clipped - 145 lines]
>> >> >
>> >> > Any assistance would be GREATLY appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.