Report to form then to Print

I have a report that gathers data from several tables, writes it in a temporary table, where it is sorted before being printed. We now want to display the sorted data on a form before printing it, edit it (add a priority code to sort the data further) and then print the report. Has anyone ever done anything similar? Any tips on making it happen?

From your description of the existing Report, it sounds like you already have a good knowledge of “Just-In-Time” Sorting. Check out this link for some ideas and an example database which contains both a Form and a Report using this “On-Demand” Sorting technique: http://www.navisioner.com/html/jitsort.htm

Yep, I have done something similar to reduce database space requirements due to new keys that would otherwise be necessary. Hints: 1) make sure to have a clean temporary table, there shouldn’t be any problem with “old” data, nevertheless I would recommend a “DELETEALL”… in the OnPreReport trigger 2) Grouping can be handled really nice: you define a single key and fill the fields of your temp table in the desired grouping order… 3) When filling the temp table you’ll need to check if your record is new (create new one) or if your record already exists with the primary key values (increment the value fields, amounts, etc.) 4) Filling the temp table is really fast, so no worries there. Saludos Nils

I already do a DELETEALL in the temp table before running the report and don’t have any problems filling and reading from the temp table. It works really sweet. The challenge is to add another sort on-the-fly, while viewing the sorted data (from the temp table)and then print the report.

You have two possibilities: 1) If your sorting fields are all of the same type you could fill your temp table according to your desired sorting and you only have a single (primary) key in your temp table E.g. you have one requirement that should show: “customer no. - item category - item group - item no” and another one that shows “item category - item group - item no - customer no.” As all these fields are of the same type, while filling your temp table you decide which field goes to which “position” in your temp table. 2) You define the keys you requiere in the temp table and set the requested key in the OnPreDateItem trigger of the temp table dataitem in your report (with SETCURRENTKEY). As your temp table doesn’t permanently contain data, database space will only be required while running the report. Saludos Nils

I have a similar issue, based on 2). I run the report which gets the data and populates the temp table, and is then sorted by the key on the temp table. The form based on the temp table works fine, but how to run a report from there? I am missing something fairly simple as i cannot seem to get the data for the report. (At present I have three reports! one to put in form one to export to excel and one normal) Any help appreciated!

One report can do all of this. After writing the data to the temp table, perform a read from the temp table and do all the pritning on the data item that is performing the read from the temp table. Example- data item- Customer (read) data item- Job (read) then write to temp from both Customer and Job. data item- temp (read sorted data) and print report. That should solve your problem, but not mine. I still want to display teh sorted data, insert additional data, and sort it before printing the report.

Mary, I don’t quite get your problem, could you please provide more details on what you want to achieve exactly. I assume that you use an Integer dataitem to print the temp table, therefore you can simply apply any SETCURRENTKEY to the temp table before “printing” the temp table data. Saludos Nils

I am not having a problem with sorting the data. I want to preview the sorted data on a form where I can edit/add additional information and then print it. I’ll try and make it more clear- I am printing a production schedule which gathers data from several tables. It is then sorted and grouped by machine and due date. I want to add the ability to view this data on a form and set a priority for the days work before printing it. I have to be able to see what(quantityand type of work) is scheduled for each day in order to set the priority. The prioirity is based on the type of work, how much is scheduled for future dates, how much work can be accomplished and a few other things. But I must see the schedule before I can set the prioirty, which is my problem. I need to display it on the screen, enter the prioirty and then print it. Right now the only way to view what is scheduled is to print the report and then go to the data entry screen to set the prioity and then run the report again. I’m just looking to save a bit of time and a few trees.

I don’t see any reason why this shouldn’t be possible. The only point that changes is that your temp table is that temporary anymore. You’ll need to fill a normal table once you are opening your form, modify/insert the necessary lines and then print these table. Everytime a user opens this form, you’ll have to delete the existing data of your table and refill with current data. If you define a complete temporary table for your form, I don’t see any “easy” way to pass this temporary table to a report… Saludos Nils

Hi Mary, maybe I don’t understand something, but I think that all you need is to call form on temp record before printing it: FORM.RUNMODAL(FORM::“YourForm”, TempRec);

Thanks, Viktoras. It works just like you said. Of course without my grouping and totals. I was making this way harder than it really was. [:D]