在部件中以看到Crystal Report Control的控件,做了一个"report1.rpt"的报表文件在工程路径下,可是在运行时报错:"report1.rpt"文件不能加载代码如下:
CrystalReport1.ReportFileName = app.path & "\report1.rpt"不知道是什么原因,请高手指点!首次使用,实在摸不到头脑!谢谢!

解决方案 »

  1.   

    with rpt1
    .reportfilename=app.path & "\rpt1.rpt"
    .discardsavedata=true
    .reportsource=crptreport
    if ispreview then
    .windowstate=crptmaximized
    .windowcontrols=true
    .destination=crptotwindow
    else
    .destination=crpttoprinter
    endif
    end with
      

  2.   

    If Right(App.Path, 1) = "\" Then
              Cry1.Connect = "ODBC;DATABASE=" & App.Path & "DATA\ZLGYSR.MDB;UID=;PWD=;DSN=ZLGYS"
            Else
              Cry1.Connect = "ODBC;DATABASE=" & App.Path & "\DATA\ZLGYSR.MDB;UID=;PWD=;DSN=ZLGYS"
            End If
            Cry1.SQLQuery = ""
      
            Cry1.Destination = crptToWindow
            On Error GoTo ERRREP
            If Right(App.Path, 1) = "\" Then
              Cry1.ReportFileName = App.Path & "REPORTS\gys.rpt"
            Else
              Cry1.ReportFileName = App.Path & "\REPORTS\gys.rpt"
            End If
      
            Cry1.WindowState = crptMaximized
            Cry1.Action = 1