report grouping

i have created a report based on the purch. recpt lines to show receipts and direct unit cost. I have got this to sort by item no., then vendor. This works fine. I know want to further this by adding the purch rcpt. header in order to be able to run the report filtered by posting date, and also, use the currency code/rate contained in the header, so that I can then show the direct unit cost in LCY If i assign the header as the prime data item, then this will lose the sorting which i require. is there anyway in which i can filter by posting date, and also use the currency code. (this would be along the lines of if currency code = 0 then dir cost = direct cost else dir cost = dir cost / currency code) thanks :smiley:

In the OnAfterGetRecord trigger you could check if a record matches your posting date filter (add two glabel date variables with from Date to Date and add these in the request form). In the trigger itself you call a get on the header and if posting date is not right then just CurrReport.SKIP that record. Same with Currency factor: You already have the header in access. If “Currency Factor” <> 0 then just calculate “Direct Unit Cost” := “Direct Unit Cost” * PurchHeader.“Currency Factor”; as you are not calling a modify, this calculation is just temporary and will not change existing records. Nevertheless the CREATETOTALS would take this change into account. (Even if it does not make sense to sum “Direct Unit Cost” directly without multiply by quantity). This is just an example.

Thanks I have “sort of got” this working based on the above!! The only problem which i am now getting is an error message “division by zero 0/0” (i have checked the entry to ensure that there are prices and currency rates there) this only happens when i put a date range in the options; and seems to be due to one entry which is not in the date range. ie : from date 01/01/05 to date 30/01/05, and falls over on an entry from Oct 04. if the date ranges were blank, then the report does not fall over. The entries which i have seen seem to be in the correct date range.


PRH.GET(PRL.“Document No.”); IF NOT (PRH.“Posting Date” > FromDate) AND (PRH.“Posting Date” < ToDate) THEN CurrReport.SKIP; IF (PRH.“Currency Factor” = 0) THEN DUC := PRL.“Direct Unit Cost” ELSE DUC := ROUND(PRL.“Direct Unit Cost” / PRH.“Currency Factor”,4);

Also do I need an “=” in the posting dates (ie so if i put 01/01 it will include 01/01, rather than starting at 02/01) Thanks