运行时错误'2489:对象'优点列表'未打开

时间:2019-10-17 13:20:05

标签: database vba ms-access

我正在尝试通过表单按钮打印一个名为“绩效列表”的报告;
这是我写的代码:


Private Sub CreateKey_Click()

    Dim Prompt, Title, Response

    Prompt = "All merit Lists will be Created!" & vbCrLf & "Do you want to print them?"
    Buttons = vbYesNoCancel
    Title = "Merit Lists Created!"
    Response = MsgBox(Prompt, Buttons, Title)

    If Response = 2 Then
        DoCmd.CancelEvent
        MsgBox "No Data was changed.", vbExclamation, "Cancelled!"
    End If

    If Response = 6 Then
        DoCmd.OpenQuery ("Merit List Generator")
        DoCmd.OpenQuery ("Merit List Creator")
        DoCmd.OpenReport "Merit List", acViewNormal, , , acHidden
        DoCmd.SelectObject acReport, "Merit List"
        DoCmd.PrintOut acSelection
        DoCmd.Close acReport, "Merit List"
        DoCmd.Close acQuery, "Merit List Creator"
        DoCmd.Close acQuery, "Merit List Generator"
    End If

    If Response = 7 Then
        DoCmd.OpenQuery "Merit List Creator"
    End If


    QuotaVal.Value = Null
    GroupVal.Value = Null
    If Response <> 2 Then
        MsgBox "Successfully Completed.", vbInformation, "Merit Lists Generated!"
    End If

    OMCheck.Value = True
    OMCheck.SetFocus
    QuotaVal.Enabled = False
    GenerateKey.Enabled = False
    CreateKey.Enabled = False
    CreateAllKey.Enabled = False
    QuotaVal.Value = Null
    SessVal.Value = Null
    MeritListVal.Value = Null
    GroupVal.Value = Null

End Sub

我尝试打印它而不以'acHide'模式打开它,但它仍然给我同样的错误:

  

运行时错误“ 2489”:对象“优点列表”未打开。

顺便说一句,我没有任何打印机。
是因为没有打印机还是其他原因?

0 个答案:

没有答案