CRYSTAL REPORT need help (Passing parameter)

CRYSTAL REPORT need help (Passing parameter)

Postby dutch » Wed Apr 12, 2017 3:35 am

Dear All,

I need to use CRYSTAL REPORT XI but I cannot run the sample program from Fernando González Diez's sample. I occur an error as picture.

I use xHB, FWH1612, BCC7 and CR XI.
Imageimage hosting
Code: Select all  Expand view
// Our first Window in FiveWin !!!

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oWnd, oActiveX, oCRApp, oRpt

   oCRApp := CreateObject("CrystalRuntime.Application.11")
   oRpt   := oCRApp:OpenReport("C:\Users\dutch\Desktop\CR11\testcr11.rpt")
   
   DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
      TITLE "Welcome to " + FWDESCRIPTION COLOR "W/B"

   oActiveX := TActiveX():New( oWnd, "CrystalReports11.ActivexReportViewer.1" )  
   oWnd:oClient := oActiveX
   oActiveX:SetProp( "ReportSource", oRpt )
   oActiveX:SetProp( "EnableStopButton",     1  )
   oActiveX:SetProp( "EnableAnimationCtrl",  0  )
   oActiveX:SetProp( "EnableCloseButton",    1  )
   oActiveX:SetProp( "EnableExportButton",   1  )
   oActiveX:SetProp( "EnablePopupMenu",      0  )  // revisar, es interesante pero da error
   oActiveX:SetProp( "EnableRefreshButton",  0  )
   oActiveX:bOnEvent = { | event, aParams | EventInfo( event, aParams, oRpt, oActivex  ) }
   
   oActiveX:Do( "Viewreport" )
   
   ACTIVATE WINDOW oWnd ;
      VALID MsgYesNo( "Are you sure?", "Do you want to exit?" )

return nil
 
function EventInfo( event, aParams, oRpt, oActivex )
   local cMsg := cValToChar( event ) //+ CRLF
return cMsg


Thanks for any help or idea.
Last edited by dutch on Wed Apr 19, 2017 8:52 am, edited 1 time in total.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: CRYSTAL REPORT need help

Postby AHF » Wed Apr 12, 2017 8:52 am

Dutch,

Just as a guide line.

Code: Select all  Expand view

  oCrystal := CreateObject("CrystalRuntime.Application.11" )
  oReport  := oCrystal:OpenReport( cReport)
  if(!empty(oReport:ReportTitle),oReport:ReportTitle,strtran(cfilenopath(alltrim(creport)),".RPT"))
  oReport:DiscardSavedData()
  oReport:SetDialogParentWindow(nHwnd)  //our window app?

  oSection := oReport:Sections:item("PHb") //REPORT HEADER B
  oSection:AddPictureObject((cLocal)+"\logo.jpg",0,0)

  //databse and tables location
  oDbName   := oReport:Database
  oDbTables := oDbname:Tables
  nTables :=  oDbTables:count()

  //reassigning new tables and datasource
  for n := 1 to nTables
      oDbTable := oDbTables:Item(n)
      oDbTable:dllname := "crdb_ads.dll"
      oProp := oDBTable:ConnectionProperties()
      oProp:DeleteAll()

      if rddrddsetdefault() ="ADS"
     oProp:add("DatabaseName","DSN=ADS_CDX;Datadirectory="+
                         ((cLocal)+"\mydatadictionary.add")+;
                        ";ConnectionHandle=alltrim(str(nHandle))"+;
                        ";Compression=Internet;DefaultType=FoxPro;ServerTypes=7"+;
                        ";AdvantageLocking=ON;CharSet=OEM;Language=ANSI;Locking=RECORD"+;
            ";UID=crystalreports;PWD=mypass"+;
            ";EncryptionPassword=mypass")

      else
          oDbTable:location := (cLocal)+"\"+oDbtable:name+".dbf"

      endif

  next

  oFormulas:= oReport:FormulaFields
  nFormulas := oFormulas:count()
    for n := 1 to nFormulas
        oFormula := oFormulas:item(n)
        //test formulas
        do case
          case upper(oFormula:name)= "
{@company_name}"
               oFormula:text  :='"
'+alltrim(aDtempresa[1,1])+'"'+chr(0)

        endcase

    next

    oReport:ExportOptions:Reset()
    if lLetter
       oReport:ExportOptions:DestinationType := 1
       oReport:ExportOptions:FormatType := 35
       oReport:ExportOptions:RTFExportAllPages := 1

    else
       oReport:ExportOptions:DestinationType := 1
       oReport:ExportOptions:FormatType := 31
       oReport:ExportOptions:PDFExportAllPages := 1

    endif
   

    DEFINE ICON oicon NAME "
FOLLOWUP"

    DEFINE WINDOW oWnd ICON oicon TITLE cTitle

    oCRViewer := TactiveX():New(ownd,"
CrystalReports.ActiveXReportViewer" )

    oCRViewer:EnableExportButton :=1
    oCRViewer:EnableStopButton:= 1
    oCRViewer:EnableNavigationControls:=1
    oCRViewer:EnablePopupMenu:=0
    oCRViewer:EnableCloseButton:=0

    if !lSql
       oCRViewer:DisplayGroupTree:=0
       oCRViewer:EnableDrillDown:=0
       oCRViewer:EnableGroupTree:=0
       oCRViewer:EnableStopButton:= 0
       oCRViewer:EnablePrintButton  := 0 //20.10.14

    endif
     
    oCRViewer:ReportSource:= oReport

    oCRViewer:ViewReport()
    oCrViewerZoom:=75

    oWnd:oClient := oCRViewer

    ownd:setmenu(MsgB(ownd,oReport,oCrViewer,creport,cuser,nport,ldocelect))

    ACTIVATE WINDOW oWnd MAXIMIZED ;
    VALID (oReport:CancelPrinting(),oCrystal:CanClose(),oReport := nil ,.t.)
Regards
Antonio H Ferreira
AHF
 
Posts: 838
Joined: Fri Feb 10, 2006 12:14 pm

Re: CRYSTAL REPORT need help

Postby dutch » Tue Apr 18, 2017 5:15 am

Dear Antonio,

Thank you so much, I can do it now.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 121 guests