All VBA Errors being supressed by setting AllowSpecialKeys to False - ms-access

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?

Related

Suppress warnings in ms-access VBA

While developing forms in Access VBA I am trying to prevent access from adding a new record and then not giving any warning message. I can stop the record from being inserted but cannot supress the warning message. I have set warnings to false on the after update event (and set warnings to true on the close event ). Can anyone tell me which events I should code for this. The reason for doing this is only while I develop the forms
Are you using a click event for any buttons? If so I would just suppress warnings in there. This setting will remain this way until you close the database and open it again.
DoCmd.SetWarnings (False)

Access 2010: Error message goes away when I open visual basic

Currently finishing up making a database and ran into a problem. I have a continuous form with a button to "Update Notice" next to it. It worked fine until I saved and closed the database. Then I suddenly began getting an error that said, "The expression On Load you entered as the event property setting produced the following error: Object or class does not support the set of events". I get a similar error message when I close the form.
The field it is affecting is a date field, that is set to inactive if the status of the record is "Open" and active if the record is "Resolved". This is now always active.
The really weird part is that as soon as I open and close the Visual Basic window, it works. The error message goes away and the date field behaves as expected.
Any ideas why this would be?
I can always go back to a prior version of the database and work from there, but I'd like to avoid regressing in my project!

How to increase VBA error output to diagnose consistent crashing after "File not found" error

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.

Suppress MsgBoxes on launching Access OR Prevent form opening on launch?

To preface this, I messed up.
I have a function that runs for each item in the database, to compare against a given value. I added a MsgBox to the code in order to check values for debugging. This function runs when the default form for the project (the one that loads when I launch Access) loads-- on every record in the database. Currently, that's slightly over 13000 items.
Is there any way to suppress the messages, launch the project without loading that form, or edit VBA from the project without launching the project?
EDIT: I've just realized that I can press ESCAPE during a MsgBox display to abort the query. Problem solved.

MS Access Treeview error loading ActiveX control [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
MS-access doesn't catch treeview events after win sec-update
recently an error appeared with a Treeview element in my access form.
The expression Expand you entered as the event property setting produced the following error: There was an error laoding an ActiveX control on one of your forms or reports.
When I click "OK" (only opportunity) the next error appears (Expand is replaced by MouseMove, MouseDown/Up, DblClick etc.), when I press Keys the KeyDown/Up/Press Message appears etc.
When I interact with the TreeView then the "Expand" is replaced by e.g. NodeClick or Collapse.
Every message only appears once, when I performed every possible Event no message pops up - but the treeview doesnt work, it doesnt open any form (the treeview is used as a menu).
The mysterious thing to me is - last week those Access Databases all worked fine - we have a database for every customer (frontend and data together) and now suddenly every database 'crashes'. I assumed that the ActiveX Treeview Control was changed by a Windows Update or something similar but also an old WinXP laptop throws the same error messages.
Even a database that hasnt been opened for 2 weeks and definitely worked back then doesnt work anymore. So from my point of view there cant be anything in the code that is wrong.
Nevertheless I tried to set a breakpoint in the Form_Load event, but the Expand Error already pops up before the first line of OnLoad is executed.
The OnLoad Event is the only event that is specified (GUI says "Event Procedure", its VBA Code only) and all other fields are blank (and no code specified).
I created a blank VBA for e.g. MouseMove, but the error still appears.
What is this error and where does it come from? Hope anyone can help.
Regards,
Matthias
P.S.:
My Treeview Project
Via this Link you find the files for a treeview project in MS Access (mentioned in the first answer). When I download these files the same kinds of error appear.. so it definitly has to do with the activeX controls, right? Is there anybody where these files work, and if so - why? Hope anybody can help..
I was having the same problem - treeview worked last week not today in either 2007 or 2010 Access, multiple PCs. Problem was Windows update. (See link http://support.microsoft.com/kb/2687441). I created and ran the batch file as indicated in the kb article and my Treeview now works.
I got the same error. I found the solution in the following link:
http://mymsaccessblog.blogspot.nl/2008/09/my-teeview-project-episode-5-using.html
I added the following sub listed below and adjusted it with the key I used and it worked.
I hope this helps you as well. Sorry if the formatting is not good. First time I post anything
Private Sub xProductTreeview_Click()
Dim nodSelected As MSComctlLib.Node ' a variable for the currently selected node
Set nodSelected = Me.xProductTreeview.SelectedItem ' get the currently selected node
If nodSelected.Key Like "Prod=*" Then ' are we on a product node
ElseIf nodSelected.Key Like "Cat=*" Then ' are we on a category node
Else ' somehow this is neither a category or product node
End If
End Sub