MS Access Treeview error loading ActiveX control [duplicate] - ms-access

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

Related

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!

Access Application.Quit not working, SharePoint Web Database

In my database (Access 2013, .accdw), I am checking the user's current version in the Form_Open event. If it is not up to date it triggers an external command to download a fresh copy and then is supposed to close itself to allow for the update. The problem is that after Application.Quit is triggered, access closes but instantly reopens, blocking the download. I've stripped out all the code I can to isolate the problem.
If 1 = 1 Then
Application.Quit
End If
Simplified pretty far, right? It should always just close as soon as the form is opened. With this as the only code in my Form_Open event which is the only code in the form, it still closes, reopens, and then closes again. Docmd.Quit has the same effect. I've tried too many variations to enumerate. In a button this code works fine, but I need it to run the check before it loads any data (the linked tables may be being altered while we change versions).
Any ideas how to make it stay closed the first time it closes?
I think it reopens because your external code (.bat file ?) reopens it. It's not an Access problem. Have you checked the numerous tools you can find for Access automated client deployment ? Here are the first 2 I found:
http://www.databasejournal.com/features/msaccess/article.php/3286111/Automatically-Deploy-a-New-Access-Client.htm
http://www.devhut.net/2015/06/30/ms-access-deploying-your-database-front-end-to-your-users/
Your code works for me in a Form_Open(), but then this is Access 2010 and no Sharepoint.
You may have better luck by Creating an AutoExec macro that calls an initialization function that does the version check, instead of having a form open automatically.
If the version check is ok, then open your start form from the function.
The easy work-around is to always fetch the current version and then launch it.
This way there's no fuzz and the user always run the latest version.

I am getting a C++ runtime error while running access vba module. Consistently reproducible

I have taken 2 sample databases from online - one for a calendar and one for drag and drop functions - and pulled some code together for a result that is ALMOST functioning as I had hoped.
There is a function to build/refresh the calendar, which works perfectly.
The drag and drop functions work perfectly. (The item is updated in the table to reflect the new date.)
When I drag and drop, the calendar doesn't automatically refresh. If I click next month then last month (which call the refresh function with a new date), the changes are reflected as expected.
The problem is when I try to automatically call the refresh function after a drag/drop event. Access crashes every time I call for a refresh in the code after drag/drop, regardless of where I put the call.
The error says:
Microsoft visual C++ Runtime Library
Runtime Error!
Program: C:...
This application has requested the Runtime to terminate it in an
unusual way. Please contact the application's support team for more
information.
I have tried:
I thought it might be trying to refresh too fast, so I added a pause
function and had the program wait 10 seconds after dropping before
refreshing. Still crashed.
I did a compact and repair on the database.
I ran /decompile from the command-line on my accdb file.
I exported the relevant form, tables, query and module to a new accdb
file.
I have tried to re-register the libraries checked under references.
(RegSvr32 "Path to library file") The only one that succeeded was
vbe7.dll. The "MS access 14.0 object library", "OLE automation", and
"MS Office 14.0 Access Database Engine Object" don't contain a
DllRegisterServer method, so regsvr32 did not succeed with those. There are no other
references checked. Still crashes.
I have tried countless places to insert the call to refreshcalendar()
I have stepped through the code and verified the exact place that the
crash happens. It is commented in the code.
Here is a link to the database.
To reproduce the problem:
Open frmsubCalendar.
There are 2 entries in May 2014 that can be dropped to other days on the calendar. I can then click the prev/next month buttons on the form, and when May reloads, the change has been made. But if I go into mod_drag_drop under the sub dropdetect() and uncomment the lines noted in the comments, the refresh will crash access at the end of the dropdetect() sub.
I cannot figure out how to make the calendar refresh automatically after a drag/drop event without access crapping the bed.
I realize this is a bit outdated, but I had a similar issue and didn't see this one being answered, I figured I'd add this answer for posterity. :) I discovered it was caused by a reference to a function by the form name. I had the following call in a module:
lContractCt = Form_Census.lContractCt_f(bIsMembers)
Where lContract is a Long, there is a form named Census and a public function in that form called lContractCt_f.
I moved the function to a module (so the Form_Census reference wasn't necessary any more). And changed the call to:
lContractCt = lContractCt_f(bIsMembers)
This fixed the error. So, I would check if you have any public function references going from a module to a form and move those public functions into a module. I also saw a similar thread with a different form reference, via Forms![Census], for example.

Method or Data Member Not found for every control or event

Got a weird problem. I was debugging some code for a form and everything was working as intended for the most part when suddenly I began to get a "Method or Data Member Not Found" for every event of my form. It's like my form suddenly does not recognize any of my controls or events. I have all of my methods properly closed and did not rename any controls.
Any ideas on what would be the root of "Method or Data Member Not Found" for every single control with an event?
Thanks
Importing into a fresh database as talbright suggested gave me more descriptive error messages.
A fresh import, compact&repair, and renaming of appropriate control fixed the problem from occuring. As Remou suggested, regular maintenance can help prevent these sorts of problems.
edit for future readers: This problem occurred while using a shared front end file. So don't do that if possible.
I've found that any MISSING: reference can make the simplest of code fail.
Check in the visual basic window
Menu Tools -> References
look down the checked refences to see if any are MISSING
I just fixed the same error by renaming text and combo boxes something not so close to a concatenated Table & Field string. Actually just prepended those names with "tbx" and "cbx".

MS Access “Update or CancelUpdate” error using Find dialog

We have an MS Access 2007 database with a simple form displaying table data. We use the Find dialog (click the binoculars on the Home ribbon) to locate records we want. This can cause an error under specific circumstances.
Steps to reproduce the problem:
Open the form.
Open the find dialog.
Edit some field within the record.
The record is now in update mode
(you'll see the pencil in row's
"gutter" area).
Without saving the record, click on
the ALREADY open Find dialog.
Search for a record that can't be
found.
Click on the form again. The record
is still in edit mode (i.e. the
pencil still shows). Attempt a save
or edit some other field.
This message box will display
"Update or CancelUpdate without
AddNew or Edit." You can click OK or
Help buttons.
Clicking the Help button shows:
You tried to call Update or CancelUpdate or attempted to update a Field
in a recordset without first calling AddNew or Edit. (Error 3020)
On a Microsoft Access database engine database, you called the Update or
CancelUpdate method but did not use the AddNew or Edit method before writing
data to a record.
On an ODBCDirect database, this error occurs when you attempt to write data
to a record without first calling AddNew or Edit.
We’ve reproduced this in a new database where there is no VBA code. So the problem is solely within MS Access, and you should be able to reproduce it easily.
If you save the record before doing the find, the problem doesn’t happen. Unfortunately, we have users doing a find while the record is still in edit mode.
We’ve tried setting up form-level, data-field-level, and Access application level events and error handling. Nothing can detect or catch this situation. There is no way within VBA to detect if the Find dialog is active.
Does anyone have any ideas for preventing the error or a way to save the record before the find occurs? Our best thought right now is to create an AutoHotkey or AutoIt script that waits for the Find dialog to have focus. We’ll then send a Ctrl+S to save the current record to force a save.
#CodeSlave's answer suggests a possibility to me:
Instead of simply removing the binoculars from the toolbar/ribbon, instead change what the binoculars do. That is, have it call code that saves the current record if it's dirty and then launches the FIND dialog.
Now, there'd need to be some code to check that a form was open, and that it had a recordsource (testing the .Dirty property errors if there's no recordsource), and that a field has the focus, but all of those things are doable. Likely many of them (except the last) would be taken care of by showing the toolbar/ribbon only when the form is loaded, or by editing the default toolbar/ribbon when the form opens.
But this would be much less crazy than using an out-of-process solution, and your users wouldn't know any difference.
I'd suggest that you've found a bug that was introduced in MS-Access 2007. However, I have not been able to duplicate it on my copy. I presume we're both up to date on our patches, so perhaps there is something more subtle happening.
If you're wanting to force the record to be saved, use one of the the following - not a CTRL-S
if me.dirty then Me.Dirty = false ''(n.b. often the preferred method)
Docmd.RunCommand acCmdSaveRecord
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70 ''(n.b. deprecated)
The problem as I understand it, is that if they edit the form after the "find" is already open and then do the "find" the get the error.
I'd try one of two things:
Find a way to close the built in find form, and do so whenever you make the current record dirty (On Dirty)
Add your own "find" button to the form (not opening the built in find form), and hide the one on the ribbon.
The hack, work-around we came up with was to write an AutoIt script which can watch for when the Find dialog gains focus and save the record if it has changed.
We didn't want to distribute the script separately from the database, so the the script was added to a database table as a Blob. The database's AutoExec macro runs some VBA code that pulls the script out of the Blob table and starts the script.
When the script detects that the Find dialog has focus, the script runs a VBA macro in the database. The macro checks to see if the current record is dirty. If dirty, the macro forces a save. Also, the AutoIt script is stopped when the database is closed.
This is all pretty awkward, but it works.