0

我写了这段代码,但我得到“运行时错误'91':”

Private Sub Command1_Click()
    Set rs = New ADODB.Recordset
    openConnection

    If Me.cmbMonth = "" And Me.cmbYear = "" Then
      MsgBox "Please select MONTH and YEAR"
      Exit Sub
    End If

    With crystalrpt

        .ReportFileName = App.Path & "\Report\VariableReport.rpt" <-- ERROR IS HERE
        .SelectionFormula = "{SW.dtaMonth}='" & cmbMonth.Text & "' and {SW.dtaYear}=" & dtaYear.Text & "" & _
        " and {SFW.dtaMonth}='" & cmbMonth.Text & "' and {SFW.dtaYear}=" & dtaYear.Text & "" & _
        " and {OT.dtaMonth}='" & cmbMonth.Text & "' and {OT.dtaYear}=" & dtaYear.Text & "" & _
        " and {CL.dtaMonth}='" & cmbMonth.Text & "' and {CL.dtaYear}=" & dtaYear.Text & "" & _
        " and {RM.dtaMonth}='" & cmbMonth.Text & "' and {RM.dtaYear}=" & dtaYear.Text & "" & _
        " and {EL.dtaMonth}='" & cmbMonth.Text & "' and {EL.dtaYear}=" & dtaYear.Text & "" & _
        " and {TRANS.dtaMonth}='" & cmbMonth.Text & "' and {TRANS.dtaYear}=" & dtaYear.Text & "" & _
        " and {WD.dtaMonth}='" & cmbMonth.Text & "' and {WD.dtaYear}=" & dtaYear.Text & "" & _
        " and {MP.dtaMonth}='" & cmbMonth.Text & "' and {MP.dtaYear}=" & dtaYear.Text & "" & _
        " and {NONSTOCK.dtaMonth}='" & cmbMonth.Text & "' and {NONSTOCK.dtaYear}=" & dtaYear.Text & "" & _
        " and {PACK.dtaMonth}='" & cmbMonth.Text & "' and {PACK.dtaYear}=" & dtaYear.Text & ""
        .WindowTitle = "Report"
        .Action = 1 'Will Show The Report

    End With

End Sub
4

1 回答 1

0

您可能正在尝试从您测试它的机器上存在的类创建一个类(对象)的实例,但不是在它被部署到的机器上......例如,我碰巧要知道我可以使 VB 程序利用 Nero Burning Rom 的类......我可以创建一个 nero 对象,并使用它的方法和属性......但这仅适用于具有 Nero 的机器安装的库。如果未安装,当您尝试创建对象时(通过与 new 或 createobject 的早​​期或后期绑定),应该引用该对象的变量仍设置为 Nothing,因为库未能创建请求的实例班级.....

于 2012-04-24T13:02:59.203 回答