G
graeme34 via AccessMonster.com
Hello experts
I have the following SELECT query which isused as the control source for my
Monthly Statement report..
SELECT DISTINCT A.AccountIndex, A.AccountName, SO.CustomerOrderNumber, SI.
InvoiceDate, SI.SalesInvoiceNumber, SI.TotalNett, V.VATValue, T.TypeOfPosting,
SI.TotalIncVat AS Debit, IIf([TypeOfPosting]="Customer Payment",[TransCredit],
0) AS IFFCredit, T.DateOfPosting, [Debit]-[IFFCredit] AS ItemBalance, SI.
SalesInvoicePaid
FROM tblVAT AS V INNER JOIN ((tblAccount AS A INNER JOIN tblSalesOrder AS SO
ON A.AccountIndex = SO.AccountIndex) INNER JOIN ((tblDespatch AS D INNER JOIN
tblSalesOrderLine AS SOL ON D.SalesOrderNumber = SOL.SalesOrderNumber) INNER
JOIN (tblTransaction AS T RIGHT JOIN tblSalesInvoice AS SI ON T.
TransactionNumber = SI.TransactionNumber) ON D.DespatchNumber = SI.[Despatch
Number]) ON (SO.SalesOrderNumber = SOL.SalesOrderNumber) AND (SO.
SalesOrderNumber = D.SalesOrderNumber)) ON V.VATRate = SOL.VATRate
ORDER BY A.AccountIndex, SI.SalesInvoiceNumber;
The query works fine....but I woyuld like to use some criteria in it to
restrict the number of records.....
I will try and explain the detail line on the report and it might help
someone envisage what I am trying to do..
Detail line...
Ref: Date: Details: Debit: Credit:
Item Balance:
Ihave the following code on the Format event of the subreport (detail line)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Balance <> Me.Debit Then
If Me.Credit > Me.Debit Then
Me.txtItemBalance = 0
Me.txtPostingType = " Payment (Part of " _
& Me.Credit & ")"
Me.txtCredit = Me.Debit
Else
Me.txtItemBalance = 0
Me.txtPostingType = "Payment"
Me.txtCredit = curCredit
End If
Else
Me.txtItemBalance = Me.Debit
Me.txtPostingType = Null
Me.txtCredit = Null
End If
End Sub
The problem I have is there is no criteria in the query to prevent paid
invoices for previous months appearing...
What I need is something Like WHERE NOT(If ItemBalance = 0 AND DatePart("m",
DateOfPosting) <> DatePart("m",Now())
I know this is not allowed, one reason being ItemBalance is an expression in
the query...and I'm sure there are a lot of other reasons...but I'm tryig to
give you's an idea of what I require.....
hope this is enough info...
Thanks in advance
Graeme
I have the following SELECT query which isused as the control source for my
Monthly Statement report..
SELECT DISTINCT A.AccountIndex, A.AccountName, SO.CustomerOrderNumber, SI.
InvoiceDate, SI.SalesInvoiceNumber, SI.TotalNett, V.VATValue, T.TypeOfPosting,
SI.TotalIncVat AS Debit, IIf([TypeOfPosting]="Customer Payment",[TransCredit],
0) AS IFFCredit, T.DateOfPosting, [Debit]-[IFFCredit] AS ItemBalance, SI.
SalesInvoicePaid
FROM tblVAT AS V INNER JOIN ((tblAccount AS A INNER JOIN tblSalesOrder AS SO
ON A.AccountIndex = SO.AccountIndex) INNER JOIN ((tblDespatch AS D INNER JOIN
tblSalesOrderLine AS SOL ON D.SalesOrderNumber = SOL.SalesOrderNumber) INNER
JOIN (tblTransaction AS T RIGHT JOIN tblSalesInvoice AS SI ON T.
TransactionNumber = SI.TransactionNumber) ON D.DespatchNumber = SI.[Despatch
Number]) ON (SO.SalesOrderNumber = SOL.SalesOrderNumber) AND (SO.
SalesOrderNumber = D.SalesOrderNumber)) ON V.VATRate = SOL.VATRate
ORDER BY A.AccountIndex, SI.SalesInvoiceNumber;
The query works fine....but I woyuld like to use some criteria in it to
restrict the number of records.....
I will try and explain the detail line on the report and it might help
someone envisage what I am trying to do..
Detail line...
Ref: Date: Details: Debit: Credit:
Item Balance:
Ihave the following code on the Format event of the subreport (detail line)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Balance <> Me.Debit Then
If Me.Credit > Me.Debit Then
Me.txtItemBalance = 0
Me.txtPostingType = " Payment (Part of " _
& Me.Credit & ")"
Me.txtCredit = Me.Debit
Else
Me.txtItemBalance = 0
Me.txtPostingType = "Payment"
Me.txtCredit = curCredit
End If
Else
Me.txtItemBalance = Me.Debit
Me.txtPostingType = Null
Me.txtCredit = Null
End If
End Sub
The problem I have is there is no criteria in the query to prevent paid
invoices for previous months appearing...
What I need is something Like WHERE NOT(If ItemBalance = 0 AND DatePart("m",
DateOfPosting) <> DatePart("m",Now())
I know this is not allowed, one reason being ItemBalance is an expression in
the query...and I'm sure there are a lot of other reasons...but I'm tryig to
give you's an idea of what I require.....
hope this is enough info...
Thanks in advance
Graeme