Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
3 unrelated files into one report
Message
 
 
À
26/04/2007 13:52:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01219736
Message ID:
01220213
Vues:
25
>>>>It has to, but it does not!
>>>>
>>>>And the funny thing, it showed Preview correctly but now it even doesn't show Preview anymore. If I comment SetFocus() and browse then preview shows up correctly but clicking Print button from the preview still gives me an error.
>>>
>>>Dunno. Seeme like you've forgotten to select the print cursor prior to printing
>>
>>See my reply to Edward. I know I'm dumb, but this would be too dumb even for me.
>>
>>Anyway, I'm going to work it out using private data session approach, since the focus switching trick doesn't work. That's actually a nice enhancement idea for my PrivateSessionClass. I'll add PrintReport method to it.
>>
>>On the second thought, I would not be able to make this PrintReport method generic since I still have to pass the cursor <g>
>
>Hi Naomi,
>I have it done (it is in FAQ) if you want to have a look.
>Here is the code I wrote for passing cursors between datasession layers.
>I will just modify it to try to solve yr problem.
>Try this ;
>
>
>*********************************************************
>* Sample of passing cursor between two VFP (data)sessions
>* Author Djordjevic Srdjan
>*********************************************************
>*.
>*use ...\data\customers.dbf in 0 shared ...
>*.
>
>&&Instead of above you already hv your cursor prepared with all data in it
>
>local oCursor
>
>oCursor = cur2obj( 'YouRepCursor' )   &&call to storing function (Amend cursor name accordingly)
>
>local oBo
>oBo=createobject('DataSessionToPrintOnly')
>oBo.consume_data(oCursor)
>
>
>****** Test Session (private)
>define class DataSessionToPrintOnly as session
>
>    procedure init
>        set deleted on
>
>    procedure consume_data
>        lparameters oCursor
>        =obj2cur( oCursor ,'repCursor')    && call to restoring function
>        browse normal
>        go top
>        &&Call yr report from here
>        report form ...
>
>enddefine
>
>
>************************************************************************
>*  Store Cursor to object.
>*  In fact, Creates Parser object and tells him to
>*  suck in cursor and then returns it all back to caller.
>*  Accepts 3 parameters for source alias , 'for' and 'while' conditions
>************************************************************************
>function cur2obj
>    lparameters cAlias,cForCondition,cWhileCondition
>    local oTable,sv_alias
>
>    sv_alias=alias()
>    select (cAlias)
>
>    oTable=createobject('table_parser')
>    oTable.cur2obj(cAlias,cForCondition,cWhileCondition)
>
>    select (sv_alias)
>    return oTable
>
>
>
>******************************
>*  Restore Cursor from object
>******************************
>function obj2cur
>    lparameters oTable,cAlias
>
>    create cursor &cAlias from array oTable.arrstru
>
>    if oTable.NumberOfRecords = 0
>        return
>    endif
>
>    append from array oTable.arrdata
>
>    if oTable.MemoCount=0
>        go top
>        return
>    endif
>
>    local nMemoRec, cMemoName, cMemoContent , i , j
>    j=0
>    for i=1 to oTable.FieldsCount
>        if oTable.arrstru(i,2) = 'M'
>            j = j + 1
>            cMemoName = cAlias+'.' + oTable.arrstru(i,1)
>            replace &cMemoName with oTable.arrmemo(recno(),j) all
>        endif
>    next
>
>    go top
>    return
>
>***********************************
>* Custom Object used as
>* cursor carrier
>***********************************
>define class table_parser as custom
>    OriginalAlias=''
>    NumberOfRecords=0
>    MemoCount=0
>    FieldsCount=0
>
>    declare arrstru(1)
>    declare arrdata(1)
>    declare arrmemo(1)
>
>
>    procedure cur2obj
>        lparameters cAlias,cForCondition,cWhileCondition
>        local lcArrStru,sv_rec
>
>        select (cAlias)
>        go top
>
>        this.OriginalAlias = cAlias
>        declare lcArrStru(1)
>
>        =afields(lcArrStru)
>        acopy(lcArrStru,this.arrstru)
>
>        this.MemoCount = this.count_memo_fields()
>
>        if eof()
>            this.NumberOfRecords=0
>            return
>        endif
>
>        if type('cForCondition') <> 'C'
>            cForCondition = ' .t. '
>        endif
>
>        if type('cWhileCondition') <> 'C'
>            cWhileCondition = ' .t. '
>        endif
>
>        create cursor tmpCursor  from array this.arrstru
>        select (cAlias)
>        scan  for &cForCondition while &cWhileCondition
>            scatter memvar memo
>            insert into tmpCursor from memvar
>        endscan
>
>        select tmpCursor
>        go top
>
>        if eof()
>            use
>            return
>        endif
>        this.NumberOfRecords=reccount()
>
>        if this.MemoCount > 0
>
>            local i,j,cMemoName,nMemoRec
>            declare this.arrmemo( this.NumberOfRecords , this.MemoCount )
>
>            scan
>                nMemoRec=recno()
>                j=0
>                for i=1 to alen(lcArrStru,1)
>                    if lcArrStru(i,2) = 'M'
>                        cMemoName = 'tmpCursor.' + lcArrStru(i,1)
>                        j = j + 1
>                        this.arrmemo(nMemoRec,j)= &cMemoName
>                    endif
>                next
>            endscan
>
>        endif
>
>        declare this.arrdata(this.NumberOfRecords, this.FieldsCount )
>        copy to array this.arrdata
>        use
>
>
>
>    procedure count_memo_fields
>        this.FieldsCount=alen(this.arrstru,1)
>
>        local i,j
>        j=0
>        for i=1 to alen(this.arrstru,1)
>            if this.arrstru(i,2) = 'M'
>                j=j+1
>            endif
>        next
>        return j
>
>
>
>
>enddefine
>********************************
>
>
>
>
>HTH

Thanks a lot. Yes, I already found your FAQ by searching messages here and finding a reference to it. It may come handy one day (and the same idea was recently discussed here and in Russian forum as well, where someone re-invented this wheel).

Anyway, since the problem was solved by simply moving the set focus few lines above I try to work on something else now.

Thanks again.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform