Running a report from On Insert trigger

Hi I have a table named Job for which the Job Number is the PK. The job number is generated only after certain fields on the form are filled in. I have a report which is also based on this table. my requirement is this report has to be run and printed immediately after the job number is created, if certain field(say Print Doc) value is set to true. How do I go about this? Thanx in advance. Kumar Sorry mistakenly posted in wrong forum. Edited by - mvgs on 2002 Apr 15 12:22:28

One of my customers had a simular request. I solved it by creating a new table in which the pimarykey of the record (e.g. Customer.No) is inserted from the Insert-trigger together with info wether it was an insert, a modification or whatever. By this nothing is printed immediately - the user has to activate a batch or a report which reads the “new table” and prints the relevant customer-records. And with this solution I avoid stupid errors, e.g. “printer not ready”, which maybe will lock the customer-table.

Hi Anfi what i understand from your posting is that i have to create a new table with same fields as in the job table and insert values into the new table and run the report basing on the values in the new table. Do u think there is no other way? because what i have done is i have created a temp table of job and tried to insert values and pass this table to the report, but it raises an error saying the Data Item Table view does not belong to Job table. Kumar

Hi Kumar, In your batch/report you create Var Item Record Item. OnAfterGerRecord() IF Item.GET(TempTable.“Itemno.”) THEN BEGIN Item.SETRANGE(“Itemno.”,“Itemno.”); Item.SETRECFILTER; REPORT.RUNMODAL(REPORT::Itemreport,TRUE,FALSE,Item); END; Edited by - ClausJohnsen on 2002 Apr 16 09:35:31

Hi again, Kumar. Claus’s solution says what there is to say. Another solution is not to use a batch and a report, but only a report that reads the new table directly; your choise. Remember to delete the NewTable.Record! Otherwise it will be processed next time as well!!

Hi Anfi and Claus Thank u for the answers. the solution of creating a new table has worked fine. but on the other hand Claus solution i have my doubts coz being inside the On Insert Trigger of the table i have to call this report. i cant get the job number that has been just inserted which is why i am not able to pass the current record to the report. So even if i copy this record into a temp table and do setrange on the original table as given by Claus it says the record is not found. Hope i am clear. Thanks again Kumar