On Click Error: "occurred while Microsoft Access was communicating with the OLE Server or ActiveX Control" - vba

Seems like this is has been asked a few times before.
After working on a form for a few weeks, I suddenly get the error when I click on a button: "The expression On Click you entered as the event property produced the following error: A problem occurred while Microsoft Access was communicating with the OLE Server or Active X Control."
This also happens with any control's event on the form (e.g. After Update on other text fields)
I tried re-installing Access to no avail.
Not sure if this is relevant, but I have a subform on the form as well. I have an "on-click" event that works on the subform, but when the code breaks at the following line (which worked before):
Me.Parent.orderID = Null
The error I get is: "Method 'Parent' of object '_Form_frmOrderQuery' failed
(frmOrderQuery is the name of the subform)
Anyway, this all worked before until I changed the query for the subform by adding a few more fields.
Finally: All of the event handlers (button click, after-update, etc) work on my other forms in the database.
Any help/suggestions would be greatly appreciated.
Thanks,
jeff

Figured it out, this was stupid easy. Whatever Form is having issues, just copy it and delete the old form. Rename the new form to the same as the last (so all your vba and stuff works). Done!

I've just run into a similar problem using the Access runtime environment. It seems that the problem might be with... non-Unicode lanuage settings.
Maybe the names of the columns you added to the query contain some problematic characters?
See this article for reference: https://support.microsoft.com/en-us/kb/907337. It contains a resolution, which helped me.
All the best!

As other users mentioned the problem is in use of non-English symbols in element (form control, etc.) names.
My way to solve it:
(may be unnecessary) Create an event procedure for any element on a form.
Switch to Code Editor.
Place cursor inside any procedure.
Open drop-down list with element names (the left one above the code window).
Check if you see some names with "?????" in them.
If 5 is true, then figure out what the elements are, find them on the form and rename using only basic latin alphabet.

In my case this issue occured because of accented characters.
I was running the VBA code on a computer that uses different non-Unicode language settings than the computer on which i created the event handler, the function, or the subroutine. Note This issue may also occur if the VBA code contains accented characters or special characters. Additionally, this issue may occur if an object name in the Access database contains accented characters or special characters.
The Solution that worked for me:
"If you are running the VBA code on a Microsoft Windows XP-based computer or on a Windows 2000-based computer, you may be able to resolve this issue by changing the non-Unicode language setting on the computer where you are running the VBA code. To verify and to change the non-Unicode language setting, follow these steps.
Note Because there are several versions of Microsoft Windows, the following steps may be different on your computer. If they are, see your product documentation to complete these steps.
Click Start,
click Run,
type Intl.cpl, and then click OK.
Under Language for non-Unicode programs on the Advanced tab, verify that the language matches the language on the computer on which you created the event handler, the function, or the subroutine. If the language differs, click the language that you want, and then click OK.
Restart the computer.
More here https://support.microsoft.com/en-us/help/907337/you-receive-an-error-message-when-you-start-visual-basic-for-applicati

Related

How to trap "The text is too long to be edited" error

We have an Access form bound to a backend SQL Server database. When users enter text that exceeds the data limits for the respective data column that is bound to that form control, Access displays the "The text is too long to be edited" error. I think (but haven't been able to verify) that this is error # 2221.
I'd like to be able to trap this error to have a more user-friendly message. On researching (found this and this), some coders mentioned being able to trap that error in the Form_Error event, and I found a support article with a decent example of using the Form_Error event to trap errors here. But this doesn't work for me. The Form_Error event doesn't seem to fire during this error, although it seems to have fired in the previously-referenced threads when they successfully trapped the error this way. Someone in the threads mentioned that the error wasn't trappable before Access 2002, but is since Access 2002. I have Access 365!
Any insight into whether this error is actually trappable, or how I might approach this either within the Form_Error event or otherwise?
The only 'otherwise' approach I can suggest is to prevent error instead of trapping. Normally, Text (short text) type field will prevent typing more characters than the allowed limit. However, this fails with pasted text and the referenced error is triggered.
To deal with pasted text that might be more than 255 characters, consider a memo (long text) field or an UNBOUND textbox. Use ValidationRule and/or VBA code to validate input - don't let user leave control until entry meets requirements.
I tested copy/paste and control's BeforeUpdate event was triggered.
A ValidationRule like Len([myControl])=10 Or Is Null on a memo field or UNBOUND control works with typed or pasted input.

VBA MSHTML TextInput Click Failed

I've worked on multiple web-scraping projects using Excel VBA before, but I haven't encountered this problem before. I've been googling the issue for the past few hours, but I haven't found a solution yet.
Scenario:
My webpage consists of a list-box and a text box that acts as a filter/search. Unfortunately, I can't disclose the webpage information, but somewhere in the list box elements I saw the word "JQuery". After creating an HTMLInputElement, I set it to text box object and changed its value to "TEXT". I expected the list to get update, but nothing happened. I tried to use different approaches, but they all failed.
Text_Field.Focus
Text_Field.FireEvent "onclick"
Text_Field.Value = "TEXT"
Text_Field.Click
I managed to put the text in the text box, but the clicking part does not work. When I do it manually, as soon as I type the phrase into the text box, the list gets updated immediately. Any thoughts or suggestions?
I tried to simulate the "enter key" press, but it didn't work either.
Your help will be appreciated.
Best,
Arman
Event won't fire when you operate elements programmatically. you have to simulate the events too, using document.createEventObject/inputElement.fireEvent (IE8 or lower) or document.createEvent/inputElement.dispatchEvent (IE9+).
What event you need to fire depends on what the script is interested in (onkeypress, onblur, onpaste, etc).

Excel giving "System Error &H80004005 (-2147467259). Unspecified error" message

Everytime I load up my Excel document, it repeatedly shows up with the message from the title. The two options are OK and Help. help opens Office Help which is useless for anything. Clicking OK displays another message saying "Compile error: Out of memory." with OK and Help buttons. Clicking OK brings up VBEditor with no debug line selected and no macro popped up either for that matter. Eventually, after it repeats that and complains 20 (exaggeration) more times (I think that's due to having a lot of duplicate code for ActiveX controls on each sheet). It highlights the first line (the Sub declaration) of the code below.
Private Sub ComboBox4_Change()
Range("B3") = ActiveSheet.ComboBox4.text
End Sub
Now this is dealing with an ActiveX ComboBox. Opening a file from an earlier date will give no errors. It's like after a certain date, it just refuses to work with it. And get this, it's only happening on one computer. The files are saved on a network drive, which shouldn't be causing an error.
I'm almost 100% certain I found a solution to this issue. It may have caused issues for someone else 4 years ago, but it caused issues for me today and I wanted to contribute my answer for anyone else running into the same problem.
I had enabled an "Additional Control" in the Controls Toolbox for Windows Media Player. I think when it loaded in a video file, it overran the memory. This is when I started panicking (company computer and all) and Googling and came across this and a few other articles without a real, fast fix.
The hunch: Once that video file was attempted to be loaded in RAM memory (because that's how Userforms work) it locked up all the memory Excel would allow before throwing all the errors.
What I tried from other posts in various places: I rebooted a few times (before Googling, even). I tried the Quick Repair of Office from Add/Remove programs, that didn't work. (I'm using Office 2016.)
So, what worked? I had the idea that maybe I could disable all ActiveX from loading in my file, and Googled that. I got: https://support.office.com/en-us/article/enable-or-disable-activex-settings-in-office-files-f1303e08-a3f8-41c5-a17e-b0b8898743ed and proceeded to disable all ActiveX controls in Excel. I closed the file out. Can't recall if I closed Excel but I probably did.
Then I loaded up my file. (ActiveX is totally disabled at this time.) No errors! I went to VBA (ALT + F11), opened my UserForm, and the video I had inserted and could not remove was just... gone. I saved the file. I closed the file.
I opened Excel. I re-enabled ActiveX in the Trust Center. I opened my file. Still, no more video on my UserForm (I didn't need it anyway) and no "Unspecified" (memory) errors! And, I can save again!
I hope this solution persists... if not I've got some "splainin' " to do. So far, I'm designing and using the Userform, and saving the file, with no issues whatsoever. I think it worked!
I believe the problem was that I had a user form with an acrobat reader display control (like an iframe, but for PDFs). I didn't have this reference or control on that specific computer and it freaked out. Not 100% sure, but the problem no longer exists.
I have been having a very similar problem with WindowsMediaPlayer (WMP) ActiveX control that I have in a Form. Some computers with office 2016 are giving this error code (usless the help button), this is the first post I have found about something similar with WMP, and I found it after searching for this error on ActiveX controls...
So my solution was to go to VBA (alt+F11), right clic on form that has the activex control and then remove it witohout exporting.
The big problem is, that for me, this form is the most important part of the application.
I have no mor information, if I find something I'll come back to post feedback.
I encountered this issue when trying to pull data from an access database. The query I was trying to pull from in the database was an all value query (*). Once I added the individual fields, the error went away.
I've got this error, when I create a user form which has no body section(just header). (Using this method for the messages where I don't expect a user response. Like a progress bar.
Probably, any abnormality(*)or inconsistency with the user form causes this problem.
Solution: Changed the height of the user form just a few pixel.
Just a simple trick worked for me
Go to Excel Options
Manage Excel Add-ins
Uncheck all and click ok

vb.net 2008 express: Two textboxes in a custom control

I'm making a custom control in VB.net 2008 Express. Without getting into the details, I am able to duplicate the issue as follows:
Make a blank custom control. Stick two textboxes on it. Don't add any code.
Run it and click the second textbox. (Don't click the first.) The text cursor appears of course.
Now Type... Although the text cursor moves within the second textbox, the text you type appears in the first textbox, not the second one.
I have found that this issue depends on the tab order of the controls. Whichever textbox is first in the tab order gets text typed in the other.
I have also found that if you press [Tab] to set focus on either textbox, the problem goes away.
QUESTIONS:
1) Is this a known bug in .net? (Specifically 2008 Express)
2) Will this phenomenon carry over when the custom control is brought into a larger project?
I followed the steps above and was able to reproduce it when I started with a Windows Form Control Library and ran it inside the UserControl TestContainer. I test this in Visual Studio 2008 Professional.
However, when I placed the user control inside a form in a separate Windows Forms Application project, the issue did not occur. So I'd think it's safe to say that this won't be an issue when the user control is used in another project.

Changing form name causes error message "Error accessing the system registry"

I am programming the On_Click method for the button labeled "View" in the first printscreen below. The method will load a form with data corresponding with the specific address id in the row containing the "View" button. This code worked perfectly when pointing to a target form called "Addresses". However, when I decided to rename the form "Address", I started receiving the following error message when clicking on the view button:
I did some research on the web about this error message, which lead me to try to delete any outdated references in the VBA editor. But when I clicked on Tools-->References in the VBA editor, I got the following error message:
It seems that MS Access' entries in the system registry might have been corrupted. But I am not certain of this because the documentation of this on the web is sparse and inconsistent.
Here is a link to the database on a file sharing site: http://jmp.sh/b/9Uyx6J2YzWbs8zPq2h6g
If the problem is in the database, you can recreate the problem by opening the form "Main" and clicking on the button "View" for the record shown in the printscreen above, or for other records.
Can anyone show me how to get past this error message?
my advices?
You could rename your Forms!....SourceObject to "Address" instead of "Addresses"
You could copy/paste the form, delete the original, and retry
You could install a decent debugging tool like MZ-Tools for VBA, that will help you manage your errors. Check the details here
EDIT: I used to get similar bugs years ago, when I was writing specific form event procedures. As we decided to switch to a model where forms did not need to be debbuged anymore (check this here), we stopped getting this kind of message. And I think I forgot the trick we used to solve this kind of error. If I were you:
I'd try to open another access database and import all objects ...
I'd put aside/cancel the faulty onClick procedure
And I'd install MZ Tools because otherwise VBA debugging is a nightmare ...
Since access was not liking the command button in each record of the continuous form, I choose to put the view button's logic in the on click event of a text box in each row, which I configured as enabled but locked. This produces a separate link from each record of the continuous form to a unique detail page with more of the chosen record's data.
This solution works perfectly, and is enabling me to move on with my other coding.
However, it would be nice if someone else were able to show how to get the command button solution to work.