Problem with sum in report

Joined
Sep 30, 2005
Messages
2
Reaction score
0
I have the subreport(or SQL?) problem. Access 97, Win98
There are 2 tables.
First, kniga1:
N
DateAdd
NBegin
NEnd

Second - kniga2
N
DateVidacha
NBegin
NEnd
AgentStan

Papers gets (and register by kniga1) and gives by agents (and register by kniga2). Dates of "getting" and "giving" is not koordinates in time: any date in kniga1 not without fall in kniga2.
I musn select by period - by month and by quarter: left - kniga1, ridth - kniga2. I may not create link like (DateAdd = DateVidacha). I try to create a query named Kniga1_2AllDate - collection of all dates

SELECT Kniga1.DateAdd as date1, Month(Kniga1.DateAdd) as date1Month
FROM Kniga1
where Kniga1.DateAdd is not null
UNION SELECT Kniga2.DateVidacha as date1, Month(Kniga2.DateVidacha) as date1Month
FROM Kniga2
where Kniga2.DateVidacha is not null
ORDER BY date1;

After I try to create report by Kniga1_2AllDate and to subreports in it - for data of kniga1 and kniga2, linking by date. I group this report(and subreports) by date1, by month and by quarter, and try to count sum. By month - all right! Value of field counted by formula

IIf(IsError([subreport Kniga1].[Report]![Field30])=0;[subreport Kniga1].[Report]![Field30];0)

By quarter - not... This is my problem :-(

Another method is to create report based by query
SELECT Kniga1_2AllDate.date1, Kniga2.N, Kniga2.DateVidacha as date11, Kniga2.NBegin , Kniga2.NEnd, 2 as priznak, CInt([NEnd])-CInt([NBegin])+1 as sum1
FROM Kniga1_2AllDate LEFT JOIN Kniga2 ON Kniga1_2AllDate.date1 = Kniga2.DateVidacha
where Kniga2.NBegin is not null and Kniga2.NEnd is not null and Kniga2.N>1
UNION SELECT Kniga1_2AllDate.date1, Kniga1.N, Kniga1.DateAdd as date11, Kniga1.NBegin, Kniga1.NEnd, 1 as priznak, CInt([NEnd])-CInt([NBegin])+1 as sum1
FROM Kniga1_2AllDate LEFT JOIN Kniga1 ON Kniga1_2AllDate.date1 = Kniga1.DateAdd
where Kniga1.NBegin is not null and Kniga1.NEnd is not null and Kniga1.N>1;

The report is like "fir", as example:

01.02.00 0023 0038 16
01.02.00 0057 0060 4
01.02.00 0120 0140 21
01.02.00 0140 0145 6
01.02.00 0110 0145 36
01.02.00 0160 0165 6
01.02.00 1140 1145 6

Another method - another problem :-(
I'm sorry about "small" question. I attach my problems in file. Report Kniga1_2AllDate is firs problem and Kniga1_2AllDate3 is a second.
I'm sorry about grammar - English is not my native language.
 

Attachments

  • db_vopros.ZIP
    27.3 KB · Views: 63
Last edited:

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