Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previewing an invoice as it is developed.

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
A form lets the user enters the details of a sales invoice : Header information such as customer account, reference, delivery address; and Line details (Qty, product, price, description &c) - these are entered into a grid.

When all the details have been entered, the invoice can be output (to printer, pdf or screen) using the REPORT FORM command.

Is it possible to show an image of the invoice as it developed – perhaps on the RHS of the screen? This feature is required because some of the detail lines may invoke formatting of the lines which cannot easily be shown on the grid being used for data entry.

This can be achieved up to a point by letting the user invoke the REPORT FORM . . . PREVIEW WINDOW. But in order to let the user continue entering data into the grid, he has to press Esc, whereupon the preview window closes, and focus returns to the data entry grid.

Is there a way of keeping a report preview up on the screen, and letting it be refreshed with some command as each new line on the grid is entered or altered.

Thank you
 
Andrew, the reason that you have to press ESC to let the user return to the grid is that the report preview window is, by default, modal. To make it modeless, add the [tt]NOWAIT[/tt] keyword. That will allow the user to carry on entering data while the preview is visible.

However, doing that on its own won't refresh the preview. You will have to re-generate the report each time the user finishes entering an invoice line. In other words, re-issue your [tt]REPORT FORM ... NO WAIT[/tt], probably in the grid's AfterRowColChange (and perhaps its LostFocus).

The whole thing might work better if the preview window is docked to the right of the screen - but you might need to experiment a bit to get that right.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike. The NOWAIT does the trick.

In the matter of positioning the form preview, I just check whether the form that I am running is on the left or right of the screen, and then position the window for the report on the other side.

The final lines of code which displays the form are broadly :

Code:
PUBLIC oRepForm
WITH Thisform
   lMidPoint = INT(.Left + .width/2)
   oRepForm = CREATEOBJECT("Form")
   WITH oRepForm
      .WindowState = 0   && This puts the form into windowed state.
      .height = _screen.Height - 85
      IF lmidpoint < (_screen.Width / 2)
         .left = INT(_screen.width * .5)
         .width = _screen.Width - .left
        ELSE
         .left =  1
         .width = (_screen.Width * .5)
         ENDIF
      ENDWITH
   SELECT tDetail
   REPORT FORM Salinv1 PREVIEW WINDOW (oRepForm.Name) NOWAIT
   ENDWITH

If I subsequently wish to re-display the preview - maybe some of the invoice lines have altered – and the preview is still on the screen, I find that executing the the above code again does not refresh the report. The existing image on screen seems to take precedence. Only if I click on the ‘Close’ button of the preview (so that it vanishes) am I subsequently able to re-execute the above code to see the revised state of the invoice.

Have tried various instructions to make the preview vanish - e.g. oRepForm.Release() – but this is not effective.
 
Hmm. You're right. I've just run your code and am seeing the same behaviour. However, the following should work:

First, [tt]SET REPORT BEHAVIOR 90[/tt]. This will give you a slightly different preview window, but it should basically work the same.

Then, when you are ready to close the window, do [tt]CLEAR WINDOW orepForm[/tt]. I'm not exactly sure why, but that should close the form. You should then be able to repeat your [tt]CREATEOBJECT()[/tt] and [tt]REPORT FORM[/tt]. Bear in mind that after you do the CLEAR WINDOW, the public variable will no longer exist, so be sure to re-define it. (Or better still, use a form property rather than a public variable.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
When a report shows its preview in a form you give it, closing the preview form ends the report without printing. Restarting the report should be possible, but recreation of a public variable has a buggy behaviour, IIRC and since the report has a reference to the report form it's becoming a "zombie", an object, that doesn't release unless you actually end the report. either with the exit toolbar button or the print toolbar button of the report or closing the preview. I don't know, if you'd see the new report behind the already existing.

You're using .WindowState = 0. A Form you create with CREATEOBJECT should be shown using either the SHOWmethod or setting .visible =.t., not this way.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top