请给出例子

解决方案 »

  1.   

    crystal report 里面有例子
      

  2.   

    Dim WithEvents CrReport As CRAXDRT.Report               
    Dim Appl As New CRAXDRT.Application                     
      Set Pw_Conn = New ADODB.Connection
      Pw_Conn.Open Gc_JetConStr & Gw_MDBPath
      
      '''レコードセット作成
      Set Pw_RstMdb = New ADODB.Recordset
      Call Pw_RstMdb.Open _
       (Gw_PrgID, Pw_Conn, adOpenDynamic, adLockOptimistic, adCmdTable)
      
      'Open the Events.rpt report file.
      Pw_Path = Dir(App.Path & "\Rpt_QB0090.rpt")
      If Pw_Path = "" Then
         ''レポートのパスが存在しません
        Gw_MsgDsp.Gf_EMsg_Dsp "W_C009", Err.Description, True
        GoTo ERR_RTN
      End If
      
      Set CrReport = Appl.OpenReport(App.Path & "\Rpt_QB0090.rpt")
      '日付型の変換
      
      ''システム日付の取得
      Pw_Date = Gw_OraDB.getSysDate
      Pw_Val = Gf_LeftB(Pw_Date, 8)
      If Pw_Val = "" Then
        Pw_Date = ""
      Else
        Pw_CDate.setDate = Pw_Val
        Pw_Val = Format(Pw_CDate.getWAREKI_NEN, "@@") & "/" _
                    & Format(Pw_CDate.getTUKI, "@@") & "/" _
                    & Format(Pw_CDate.getHI, "@@")
        Pw_Date = Pw_Val
      End If
      ''期間左
      Pw_Val = Trim(Gw_Kikansa)
      If Pw_Val = "" Then
        Pw_Kikansa = ""
      Else
        Pw_CDate.setDate = Pw_Val
        Pw_Val = Pw_CDate.getWAREKI _
                    & Format(Pw_CDate.getWAREKI_NEN, "@@") & "年" _
                    & Format(Pw_CDate.getTUKI, "@@") & "月" _
                    & Format(Pw_CDate.getHI, "@@") & "日より"
        Pw_Kikansa = Pw_Val
      End If
      ''期間右
      Pw_Val = Trim(Gw_Kikanmigi)
      If Pw_Val = "" Then
        Pw_Kikanmigi = ""
      Else
        Pw_CDate.setDate = Pw_Val
        Pw_Val = Pw_CDate.getWAREKI _
                    & Format(Pw_CDate.getWAREKI_NEN, "@@") & "年" _
                    & Format(Pw_CDate.getTUKI, "@@") & "月" _
                    & Format(Pw_CDate.getHI, "@@") & "日まで"
        Pw_Kikanmigi = Pw_Val
      End If
      
      CrReport.DiscardSavedData
      CrReport.Database.SetDataSource Pw_RstMdb
      CrReport.Database.Verify
      ''期間の設定
      CrReport.ParameterFields(1).AddCurrentValue Pw_Kikansa
      CrReport.ParameterFields(2).AddCurrentValue Pw_Kikanmigi
      CrReport.ParameterFields(3).AddCurrentValue Pw_Date
      
      Txt_CRViewer.ReportSource = CrReport
      
      Txt_CRViewer.ViewReport
      

  3.   

    首先建立ODBC数据源,我用的是MDB数据库,建立水晶报表文件,请参照本例,比较简单。Option Explicit
    Private Const ODBC_ADD_DSN = 1
    Private Const ODBC_CONFIG_DSN = 2
    Private Const ODBC_REMOVE_DSN = 3
    Private Const vbAPINull       As Long = 0&
    Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (ByVal hwndParent As Long, ByVal fRequest As Long, ByVal lpszDriver As String, ByVal lpszAttributes As String) As LongPublic Function CreateDSN(ByVal sTPath As String, ByVal sTDsn As String) As Long
        Dim strDriver As String
        Dim strAttributes As String
        strDriver = "Microsoft Access Driver (*.mdb)"
        
    '    strAttributes = "SERVER=SomeServer" & Chr$(0)
        strAttributes = strAttributes & "DESCRIPTION=筑龙供应商管理" & Chr$(0)
        strAttributes = strAttributes & "DSN=" & sTDsn & Chr$(0)
        strAttributes = strAttributes & "DBQ=" & sTPath & Chr$(0)
        strAttributes = strAttributes & "UID=" & Chr$(0)
        strAttributes = strAttributes & "PWD=" & Chr$(0)
        CreateDSN = SQLConfigDataSource(0, ODBC_ADD_DSN, strDriver, strAttributes)
        
    End FunctionPrivate Sub Form_Load()
      If CreateDSN(App.Path & "\ZLGYSR.mdb", "ZLGYS") <> 0 Then
        
      End If
      Dim CRY As CRAXDRT.Report
      Dim CRYAT As CRAXDRT.Application
      
      Set CRYAT = New CRAXDRT.Application
      
      Set CRY = CRYAT.OpenReport(App.Path & "\CP91.rpt")
      CR91.ReportSource = CRY
      CR91.ViewReport
    '  CRY.PrintOut True
    End Sub
      

  4.   

    请问楼上
        Dim CRY As CRAXDRT.Report
        Dim CRYAT As CRAXDRT.Application
    CRAXDRT怎样定义??