Click here to Skip to main content
15,902,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 2-Oct-17 7:40am
v2

1 solution

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.
 
Share this answer
 
v2
Comments
Miguel Altamirano Morales 2-Oct-17 14:29pm    
Thank you Dave. What I have done is: I took off the autoexec macro and set an initial form for the project.
I call now the functions supposed to run in the autoexec in the Form_open event of the form.
My problem now is that I don´t know how to run the project from this form. The break points are not working still and I cannot see the VBA code if I run it from the start.

There´s an option "Execute" in the tool bar of Visual Basic, with "Execute Sub/UserForm", I´m trying to see how it works.

My immediate need is to run the entire code from the beginning in the .accdb file.
Miguel Altamirano Morales 2-Oct-17 15:01pm    
The only way I can see the vba code, in order to set breakpoints, is loading the database holding the shift key. And if I do this, then my customized ribbon is not loaded, and is precisely in the module where the XML "onAction" tag of my ribbon fires all the forms and other procedures.

Such a mess !!!.

Is there a way to access the VBA code without loading the source database holding the shift key ?
Dave Kreskowiak 2-Oct-17 15:58pm    
Hit Alt-F11.
Miguel Altamirano Morales 2-Oct-17 16:25pm    
I have tried that several times, but it doesn't work, Dave.

I double-click the source database in the backstage list in order to execute it, and when the first form appears, I try to set the breakpoints but Access doesn't respond to the Alt-F11 combination. The only way I can see the VB code is loading the database holding the shift key. If I find a way to see the code when running the app in this way (in the source database), then I´ll solve my problem. I don´t know if it is a configuration problem.

Thanks a lot again, Dave, and please excuse me if I sound too naive with these questions, I never worked with Access before (The environment, not the vba code). I know it should be a very simple thing, and when I find it, I´ll be laughing of it, but for now I´m really in a hurry, I badly need the money.
Dave Kreskowiak 2-Oct-17 16:37pm    
About all I can tell you is to remove the Autoexec macro and move any code that was in it to its own method. You can then setup a button to call that method to start the app on butt on click.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900