report preview form problem

I posted a post related to some problem with memo fields in reports. What I've done so far was to create an intermediate table, a workbench with a single field of a character string length 95. When I need to preview or print a memo field I first format it and place every word sequentially in records of that table. It required a bit of coding but now it seems to work.

In any event, the problem I am about to inquire is not related to it at all. It was just an introduction to show that I do have a preview form filled with some meaningful stuff to the limit. Here is the weird part: once I get this preview form with the report on it it cannot be viewed OUTSIDE the confines of my main form. My forms are typically very small. I pack a lot of controls in them. The size of this project's form, for instance, is 813 (w) x 680 (h). The report has a wider area, perhaps twise as large, and I can actually read only a small subset of this area, not even the whole lines. If I move the report form sideway other parts become invisible. They are visible as long as they are not outside my project's form (813x680).

How can I change it I want this form to exist independently. Is it something related to the fact that the report form is a modal form I do not mind it to be modal, I do not want it to disappear after I moved it sideways. Other modal forms do not do it.

Thanks.




Answer this question

report preview form problem

  • MikeThom

    Sigh.

    Something tells me you changed part of the code or did not copy it over properly.  If the report name was replaced with your own report name the code will work just fine, if the report form name actually exists.

    This works on thousands of customer's computers in many different applications without problem.

    File not found is telling you that the report form you told the code was not a valid file name.  It is fairly simple to see what you did wrong. 

    What in the world are you checking for NOT EMPTY(lcFile)   There is NO POSSIBLE WAY it would be empty!!!!!  You just gave it a value on the line above!

    What you need to do is check for the existance of the file, not the value.  Here is the code for checking the existance of a file: (put this in your main.prg file)

     FUNCTION fndfile
      PARAMETER tcfile
      DIMENSION lafile[1]
      llexist = ADIR( lafile, tcfile ) > 0
        RETURN llexist

    To use this function you would put this code above the other stuff above.

    llexist = .f.

    Do FndFile in Main with "C:\VFP_Projects\Reports\MyReport.FRX"
    if llexist = .t.

    ** file exists continue with code above

    lcFile = "MyReport.FRX"

    set default to <your directory name that you want>

    ** now rest of code I gave you with the report name as (lcFile)

    else

    ** file DOES NOT EXIST cancel procedure

    messagebox("file is not found,0,"Error")

    ** do whatever you do when the file is not available

    return

    endif



     



  • c# newbie

    OK, it is a very cute idea but I ran into a snag. When I tried almost exactly your syntax I got an error message: "File not found." It was clearly pointing toward oRepForm after the WINDOW clause. I tried a few modifications of your code but soon changed the whole thing to this:

    lcFile = "C:\VFP_Projects\Reports\MyReport.FRX"
    IF NOT EMPTY(lcFile)
    CREATE REPORT (lcFile) FROM tCursor COLUMN FIELDS named ALIAS WIDTH 1
    ENDIF
    DEFINE WINDOW wRepForm AT 20,20 SIZE 400,400 IN DESKTOP NAME oRepForm FONT "Ariel",12 ;
    TITLE "report form" HALFHEIGHT CLOSE FLOAT GROW NOMDI
    ACTIVATE WINDOW wRepForm
    ON KEY LABEL ESCAPE
    SET PATH TO "C:\VFP_Projects\Reports\"
    REPORT FORM lcFile TO PRINTER PROMPT PREVIEW WINDOW (oRepForm) && NEXT 1 && PREVIEW && TO PRINTER NOCONSOLE &&
    *** close report window
    wRepForm.RELEASE()
    wRepForm = .NULL.
    RELEASE wRepForm

    You can see that I commented out a part of the REPORT FORM statement since I kept getting the same error and decided to simplify the command to focus on the essential.

    I tried many variants, I was putting wRepForm in place of oRepForm which is supposed to be just a name property. Nothing helped. I was getting the same error all along: "file not found" and in debug window I could see that it did not like the expression in parentheses. I left the parentheses out--to no avail. I am essentially at the end of all ropes now.

    I like the idea of creating a Window since your form still got stuck in VFP screen and had a morbid grey appearance. This window is on the desktop and fully movable.

    Another thing I want to mention is that although the window I've created looked nice and behaved independently, I could not see its handle in the task manager at all. I cannot figure out why.

    Also, and it is kind of weird, the size of this window was sort of given and had no relation to the parameters nRow,nCol I was setting for it. Neither the initial position of the left upper corner nor the size of the window could be changed in the DEFINE WINDOW command by any variations.

    Thanks.



  • cesar.fong

    Don hi,

    You are attacking the wrong point. I copied this part of code from VFP9 Help the first day I started doing reports about a week ago and left it there since it did not bother me. This is the code (CREATE REPORT - QUICK REPORT):

    LOCAL lcFile
    USE  ALIAS temp
    lcFile = PUTFILE("Report name","myreport.frx")
    IF NOT EMPTY(lcFile)
      CREATE REPORT (lcFile) ;
       FROM (ALIAS())
    ENDIF
    I can check for the file existance with  FILE (myReport.frx).
    I do not an error on the file. The system breaks down on the 
    container for that form. In any event, I will have to think about it further.
    Thanks.


  • shihad

    A neat IDEA!!!!

    Thanks.



  • cristy

    Try this:

    oRepForm = CREATEOBJECT("Form")
    WITH oRepForm


    .CAPTION = "Log Book Detail Report - to Close click on Print Preview Tool Bar Door"
    .WINDOWSTATE = 2 &&This will maximize the form
    .minbutton = .f.
    .SHOW()


    ENDWITH

    ON KEY LABEL ESCAPE

    REPO FORM logvwide TO PRINTER PROMPT PREVIEW WINDOW (oRepForm.NAME) NEXT 1


    *** close report window
    oRepForm.RELEASE()
    oRepForm = .NULL.
    RELEASE oRepForm

    This will create a form that should fill the screen display area completely with the report preview neatly inside.




  • report preview form problem