Hi I have an application created in Access 2007, it's front-end and back-end is split. I am trying to open the database using Access 2010 runtime, however the application crashes when I change selected item of a combo box.
I receive the following error:
"Execution of this application has stopped due to a run-time error. The application can't continue and will be shut down."
After researching the problem, a few people mentioned running the compact and repair, and found that fixed their problem, however it made no difference to mine.
However, I found most people to come back and say put some error logging in place. So I have done that, and when running on 2010 runtime, a receive a pop up message saying the following:
Error number: 2185, You can't reference a property or method for a control unless the control has the focus.
However when running in Access 2007, there is no error and the code works fine.
This is the code I have been using:
Private Sub ComboBox1_Change()
If Not ComboBox1.Text = "" Then
ComboBox1.Dropdown
End If
End Sub
My question is, why would this suddenly become an issue running on 2010 runtime, when there is no error in Access 2007?
change If Not ComboBox1.Text = "" Then to If Not ComboBox1 = "" Then
For whatever reason Access does not like you use the .Text property outside of it's strict control.
Related
I've been creating an MS Access database with VBA code performing a lot of the necessary actions as the users are not very technically literate. Everything has been working well until today when I noticed a command I was expecting an error from didn't return one.
Code executes until it encounters an error and then just stops with no message. The error details can be access through a messagebox with err.description or similar but no break occurs in the code, just an exit.
I tried creating a button on a new form that divided by 0 to force an error and received no message. I then tried it in a blank database and received the expected error.
So I went back and undid the recent changes I'd made one by one until the error messages returned. Once I set AllowSpecialKeys back to true the error functionality returned. I looked on MSDN and it says the property disables "entering break mode within a Visual Basic module by pressing CTRL+BREAK". It seems that rather than stopping the CTRL+Break combination it just disables VBA's ability to enter break mode.
I have the AllowSpecialKeys set to false to prevent the users from bringing up the Access Object explorer with F11 or the code window with Alt+F11.
So my question is I guess, can I either continue to use AllowSpecialKeys = False and still allow VBA to enter break mode, and if not is there a different way to disable the hotkeys so I can avoid AllowSpecialKeys?
Is there a way I can make the application MS Access and VBA more verbose in order to better diagnose errors from the IDE?
I open my MS Access project, I get a message dialog box, titled "Microsoft Visual Basic for Applications" with the message "File not found:" without any path specified. Opening the form file works as expected.
When I go into VBA, I can run some commands from the Immediate window. The following actions will make MS Access crash, showing a messaged box titled "Microsoft Access has stopped working":
Closing the database
Stopping the debugger (it opens being active, trying to load a form)
Selecting text of the procedure I was working on when MS-Access / VBA initially crashed.
This does not answer the question, but it seems the underlying problem has been fixed by deleting the procedure in question, letting MS Access crash and re-opening VBA.
To answer the question in your title: If the error is actually cause by VBA code, you can catch the error (using On Error Goto ...) and provide additional information based on the context of your method (the file you were trying to open, etc.). Unfortunately, there is no magical switch to make the built-in error messages more useful.
To answer the question in your question body: From what you describe, the error is not caused by actual user-supplied VBA code. Instead, your database or its VBA module is corrupt (Access crashing or showing seemingly random errors is a strong sign of that). Repair, compact and decompile your database. It might be worth checking out the VBA references as well, so see if any of those are missing.
can you execute the command resume in the immediate window ? it should send you back to the code line where the file was not found.
This is on an upgraded Access solution from 2015 to 2016. Also, new solution is using a MySQL backend database on Amazon Web Server. So I'm not sure which change may be causing the issue.
When I execute the code
DoCmd.RunCommand acCmdSaveRecord
Or, when I just move to another record, causing an intrinsic save, I get the error 2759 with the following description:
The method you tried to invoke on an object failed
Also in some conditions when I apply a filter to the form I get this error also.
Does anybody have a suggestion on how to fix this, and/or what is causing it?
Context:
I have an Access database application that was built in Access 2k. I have a custom ribbon built that I am playing around with, and I also have some user "security" in this app.
When a report opens, I want to check the username and switch to a different ribbon for specific users. I would think that this code would work:
The Code:
If GetUserName() = "admin" Then
Me.Report.RibbonName = "CustomPrintPreview"
Else
Me.Report.RibbonName = "MSToolbar1"
End If
The Problem:
This code seems to execute (and it's not doing On Error Resume Next). However when the open event ends, the report opens with no data (when there should be data). If I remove this if block, it runs fine aside from setting the correct ribbon. I should mention that if I manually set the RibbonName property for the report, both ribbons work fine, so it is not a problem with the ribbons themselves.
I'm currently using access 2007, but this will be deployed for 2010 versions as well. Does anyone know what's going on here?
I want to check wheather my database application is running in a fullversion MS Access or only with a viewer / limited MS Access.
The problem is that in a limited version a user can close the last form and then is not able to reopen any form without restart the whole application.
Private Sub Form_Unload(Cancel As Integer)
If LimitedVersion Then
Cancel = True
End If
End Sub
So the question is how to determine LimitedVersion ?
You can use:
SysCmd(acSysCmdRuntime)
It will return True for the runtime version.
However, I would never allow the last menu to be closed in an application. The people with a full version can open the application in a different way if they need access to design.
To simulate the runtime environment, you can use the /runtime switch:
For MS Access 2010, it would look something like this, note that the line break is for display purposes.
"C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE"
"z:\docs\demo.accdb" /runtime