访问:取消报告生成导致错误 2501 [英] Access: Canceling Report generation causes error 2501

查看:31
本文介绍了访问:取消报告生成导致错误 2501的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不敢相信我在这个问题上浪费了这么多时间.

can't believe I am losing so much time on this one.

我有一个订单,当我点击报告"按钮时,会出现一个对话框弹出窗口,其中包含可供选择的不同报告列表.双击选择并开始记者报道.

I have an order form, and when I click on a button "reports", a dialog pop ups with a list of different reports to chose from. Double-clicking selects and starts the correspondent report.

在其中一份报告中,有一个未绑定的文本框,我需要用户输入数据.此字段的 ControlSource 设置为其 Name 属性.报告启动时,会出现一个输入框,其中包含一个确定和一个取消按钮.每当我输入一些数据时,一切都很好.

On one of these reports, there is an unbound text box I need the user to enter data with. The ControlSource of this field is set to its Name property. When the report is started, an input box appears with an OK and a Cancel button. Whenever I enter some data, all is fine.

但是当我单击取消时,应用程序崩溃并收到一条错误消息:运行时错误 2501:操作 OpenReport 已被取消"(翻译自德语).

But when I click on Cancel, the app crashes and I get an errormessage: "Runtime Error 2501: The Action OpenReport has been canceled" (translated from German).

通过以下代码调用报告:

The Report is called through this code:

DoCmd.OpenReport vBerichtName, nAnsicht
End If   

On Error Resume Next
  DoCmd.Close acForm, "F_BerichtDrucken"
On Error GoTo 0

1) 为什么错误处理没有启动?
2)我用谷歌搜索并找到了很多奇怪的解决方案,比如微软官方说你需要安装/更新打印机驱动程序(来吧......).没有任何帮助.

1) Why does the error handling not kick in?
2) I googled and found lots of weird solutions for this, like the official Microsoft one saying you need to install/update a printer driver (come on...). None helped.

我正在为一个朋友做这件事,我通常在 linux/php、java 等上工作.如果解决方案有点明显或类似的东西,我深表歉意.

I am doing this for a friend and I normally work on linux/php,java, etc. I apologize if the solution is somewhat obvious or something like that.

推荐答案

同 Phillipe 的回答.你没有给我们整个程序,但你需要做这样的事情......

Ditto to Phillipe's answer. you didn't give us the whole procedures but you need to do something like this...

Sub MyButton_Click
On Error Goto myError

DoCmd.OpenReport vBerichtName, nAnsicht


MyExit:
   Exit Sub

MyError:
   If Err.number = 2501 then goto myExit
   msgbox err.description
   goto myExit

End Sub

这是一个常见错误,但您可以像其他任何错误一样捕获它,如果是 2501,则忽略它.
塞斯

This is a common error but you can catch it like any other error and ignore it if is 2501.
Seth

这篇关于访问:取消报告生成导致错误 2501的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆