为什么命令'stop'不会暂停执行访问VBA代码? [英] Why a command 'stop' doesn´t pause the execution of access VBA code ?

查看:179
本文介绍了为什么命令'stop'不会暂停执行访问VBA代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以前开发的Access 2010项目的源代码(.accdb文件),以便进行用户所需的一些更改和修改,当我尝试运行它时遇到了一些问题(来自源代码)并尝试通过系统模块调试执行流程。



我注意到VBA访问代码没有保留断点我我保存项目时设置,就像Visual Basic 6.0(或.NET,我记不太清楚)以前做的那样。因此,我必须再次按住shift键加载数据库,现在我知道它会覆盖初始autoexec宏的执行和加载自定义选项功能区。据我所知,这是我作为程序员与VBA代码交互的唯一方式。



我给一对夫妇添加了一个停止命令代码中的模块,尝试在运行时(仍在源文件中)模拟断点,但只能在我设置的第一个模块中工作,在自动执行宏执行的模块之一而不是第二个模块中执行当用户在自定义功能区中选择一个选项并触发onActionXML标记时触发的过程。该模块超出了autoexec宏的范围;这是我注意到的唯一特殊点。



有没有其他方法可以通过.accdb文件运行整个系统,而无需使用shift键? (使用autoexec宏开始,已经建立)



我发送的代码副本无效。在'Stop'之前的前一个Msgbox运行良好,所以我不知道为什么以下'Stop'失败(只是不暂停执行)。非常感谢你的帮助。



这是代码:



Sub OnActionTglButton(控制作为IRibbonControl,按As布局)



'XML文件中的回调名onAction



'回调一个切换按钮点击事件



MsgBoxQuitaréstemensaje,vbCritical,basRibbonCallbacks



停止



Select Case control.Id



Casetgbclientes

'在标签:tabclientes

'在组:grpclientes

parms(6)= min_pedido()

如果parametro(125)= 1则

DoCmd.RunSQL(UPDATE dbo_restricciones SET formulario ='f_clientes'& _

WHERE programa_id = 9)

Else

DoCmd.RunSQL(UPDATE dbo_restricciones SET formulario ='f_clientes_america'& _

WHERE programa_id = 9)

结束如果



.........继续



我尝试了什么:



我正在尝试隔离问题,也许是数据库的开放模式在Access中与此有关。



如果我:



1.-双击源数据库(.accdb)通过Windows资源管理器:



- 它确实隐藏了默认菜单并加载了惯用的功能区。不执行'停止'命令。



2.-输入Access-双击源数据库,他们称之为文件列表的后台:



- 它会隐藏默认菜单并加载惯用的功能区。不执行'停止'命令。



3.-输入访问 - 单击选项打开 - 在打开文件对话框中选择数据库:



- 它会隐藏默认菜单并加载惯用的功能区。不执行'停止'命令。



4.-输入访问权限 - 按住< shift>加载数据库key-直接或逐步执行autoexec宏:



- 不加载自定义功能区而不隐藏默认菜单 - 第一个停止语句有效罚款 - 第二个'Stop'语句不会暂停执行代码;这是我真正需要实现的,当用户在自定义功能区中选择一个选项时,为了看到要执行的代码。

I´m working with the source code (the .accdb file) of a previously developed Access 2010 project in order to make some changes and modifications required by the users, and I'm having certain problems when I try to run it (from the source code) and try to debug the flow of execution through the modules ot the system.

I noticed that VBA Access code doesn´t keep the breakpoints I set when I save the project, just like Visual Basic 6.0 (or NET, I don´t remember well) used to do. So, I have to load the database again holding the shift key, which now I know overrides the execution of the initial autoexec macro and the loading of a customized options ribbon. This is the only way I can interact with VBA code as a programmer, as far as I have seen until now.

I added a "Stop" command to a couple of modules in the code, trying to simulate a breakpoint at runtime (still in the source file) but only works the first one i set, in one of the modules executed by the autoexec macro and not a second one, that I set in the procedure fired when the user selects an option in the customized ribbon and the "onAction" XML tag triggers. This module is outside the range of the autoexec macro; this is the only "particular" point I notice.

Is there another way to run the entire system via the .accdb file, without having to use the shift key ? (starting, as stablished, with the autoexec macro)

I'm sending a copy of the code thats is not working. The previous Msgbox before the 'Stop' runs well, so I don´t know why the following 'Stop' fails (just doesn't pause the execution). I´d really appreciate your help.

Here´s the code:

Sub OnActionTglButton(control As IRibbonControl, pressed As Boolean)

' Callbackname in XML File "onAction"

' Callback for a Toggle Buttons click event

MsgBox "Quitar éste mensaje", vbCritical, "basRibbonCallbacks"

Stop

Select Case control.Id

Case "tgbclientes"
' In Tab: tabclientes
' In Group: grpclientes
parms(6) = min_pedido()
If parametro(125) = 1 Then
DoCmd.RunSQL ("UPDATE dbo_restricciones SET formulario='f_clientes' " & _
"WHERE programa_id=9")
Else
DoCmd.RunSQL ("UPDATE dbo_restricciones SET formulario='f_clientes_america' " & _
"WHERE programa_id=9")
End If

......... continues

What I have tried:

I'm trying to isolate the problem, maybe the open mode of the database in Access has something to do with this.

If I:

1.- Double click the source dataBase (.accdb) via Windows Explorer:

- It does hide the default menus and load the customatized Ribbon. Does not execute the 'Stops' commands.

2.- Enter Access- double click the source database in what they call the backstage of the list of files:

- It does hide the default menus and load the customatized Ribbon. Does not execute the 'Stops' commands.

3.- Enter Access - Click option "open" - Select the DB in the Open file dialog:

- It does hide the default menus and load the customatized Ribbon. Does not execute the 'Stops' commands.

4.- Enter Access - Load the DB while holding the <shift> key- Execute the autoexec macro directly or step by step:

- Does NOT load the customized ribbon and does not hide the default menus - The first 'Stop' statements works fine - the second 'Stop' statement just does not pause the execution of the code; that´s what I really need to achieve, in order to see the following code to be executed, when the user selects an option in the customized ribbon.

推荐答案

VBA支持断点。只需单击希望调试器停止的行,然后单击F9。没有必要用停止来代码。



否,断点不会随项目一起保存。是的,你必须在每次想要使用它们时设置它们。



此外,你不必每次想要运行时关闭并重新打开项目它。 Autoexec只应用于初始化代码,而不是用于运行项目中的所有内容。
VBA supports breakpoints. Just click on the line you want the debugger to stop on and hit F9. There is no need to pepper the code with "Stop".

No, breakpoints are not saved with the project. Yes, you have to set them every time you want to use any.

Also, you should not have to close and the reopen the project every time you want to run it. Autoexec should only be used to initialize the code, not to run everything in the project.


这篇关于为什么命令'stop'不会暂停执行访问VBA代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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