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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report FORM problem

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I have recently returned to VFP to produce a small app as a 4 step pageframe in a single top level form.

I want to show a report I have designed and have used ramani's code but the new form and report within it do not show on screen.

Code:
FUNCTION previewReport
PARAMETERS rptFile

oRepForm = CREATEOBJECT("FORM")
WITH oRepForm
   .Caption = "Report Window"
   .WindowState = 2
** set properties as you want for DeskTop/TopLevel
   .Show()
ENDWITH
REPORT FORM (rptFile) PREVIEW WINDOW (oRepForm.Name) ;
       TO PRINTER PROMPT
oRepForm.Release()
RELEASE oRepForm
RETURN .t.

Can someone help me over this little hiccup?

Thanks
gendev
 
This could be because your window is modeless. So the report does appear on the screen, but the form is immediately released, so you don't get a chance to see it.

The solution is to add a NOWAIT clause (afte the PREVIEW clause).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Another possible cause is the ShowWindow property.
You've created your preview form with CREATEOBJECT("FORM") and I suppose ShowWindow=0 (In screen), by default.
I may try to define your own form class, with ShowWindow=2

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
You have added these commands in your code, which closes the form for you:
oRepForm.Release()
RELEASE oRepForm
And still you are surprised that the form actually closes immediately, so fast that you don't see it?

 
I made a mistake in my previous post. I shouldn't have said add NOWAIT. That does the opposite of what I intended. But I still say you should make the window modal. You can do that by setting its WindowType property to 1.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
When I include .ShowWindow = 2 in my form's attributes I get an error when I use the debugger to watch the code execution.

What gives?

GenDev
 
Well, you can't set that in a running form. You'll have to call it with SHOW(1), but after you directed the report preview to it.

Why don't you try simpler without such a form overall?

Simply do
Code:
FUNCTION previewReport
   PARAMETERS rptFile
   REPORT FORM (rptFile) PREVIEW TO PRINTER PROMPT

A report preview window is generated anyway, you don't need to.
Or does your single form application hide _screen?

Bye, Olaf.
 
It would be useful to know why you want to preview the report in your own form. If it's just because you don't like the standard preview window (and I wouldn't blame you), you could this instead:

[tt]REPORT FORM MyReport OBJECT TYPE 1[/tt]

This will give you a better-looking preview window, with more zoom options (including a whole-page option), the option of a context menu instead of the toolbar, the ability to view two or four pages side by side, and the fact that clicking on the report no longer changes the zoom level (a behaviour which most users find infuriating).

If that doesn't mean your needs, tell us exactly what you are trying to achieve.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,

I tried REPORT FORM MyReport OBJECT TYPE 1 however no report was put to screen, however your previous suggestion of NOWAIT did work for me.

I am trying to do a very simple thing - to put a report on top of my application window to show the results of the processing my app does. I would like the whole single page report to show in full ie open.

The NOWAIT solution is OK except that I only get a small report jammed into the top left of my app's location.

I just don't know the depth of the report engines instructions I'm afraid.

Thanks

GenDev
 
I vaguely recall a bug in one of the earlier VFP9 incarnations where the report was small and crammed up in a corner. Make sure you have both SP2 releases and the hot fixes installed.

Might not have anything to do with what you're seeing, but it's still worth making sure you have all the latest versions.
 
Asked again: does your single form application hide _screen?

The standar report preview form might only get visible, if _screen is visible.

Bye, Olaf.
 
Sorry Olaf,

I forgot to answer your question.

I have _screen.visible = .f. in my app. If I use _screen.visible = .t. I get a small screen window at the top left of my monitor which I don't want as my app is a single form with a pageframe and cmd buttons outside the pageframe.

GenDev
 
Yes, then I assume the standard preview you get by either PREVIEW or OBJECT TYPE 1 remains invisible, as it's generated in screen and only creating another top level window makes your preview visible.
In the end you now have a solution with a self defined preview form and calling the report with Nowait.

Bye, Olaf.
 
If you had SCREEN=OFF in config.fpw instead of setting .Visible=.f. after it already exists you wouldn't have had this problem. Report preview shows up in a top-level form just fine, but only if SCREEN=OFF.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top