473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Don't Understand Error Message

675 512MB
This code is in a Module called from an _Click event for my form named fAAA. Variables beginning ix... are Global Long, declared elsewhere.
Expand|Select|Wrap|Line Numbers
  1. Public Sub QuickShow()
  2. On Error GoTo QuickShow_Error
  3. 'Display Quick Dropdown ListBox
  4.     If ixQuickLevel = 0 Then Exit Sub
  5.     Forms!fAAA.cboQuick = Forms!fAAA.cboQuick.DefaultValue
  6.     Forms!fAAA.cboQuick.ListRows = ixQuickCount
  7.     Forms!fAAA.cboQuick.SetFocus
  8.     Forms!fAAA.cboQuick.Dropdown
  9.     Exit Sub
  10. QuickShow_Error:
  11.     Debug.Print Err.Number; Err.Description
  12.     Debug.Print "List Rows=" & Forms!fAAA.cboQuick.ListRows
  13.     Debug.Print "Enabled=" & Forms!fAAA.cboQuick.Enabled
  14.     Debug.Print "Visible=" & Forms!fAAA.cboQuick.Visible
  15.     Stop
  16.     Resume Next
  17. End Sub 'QuickShow
It stops at Line #15, displaying in the immediate pane
Expand|Select|Wrap|Line Numbers
  1. --2147417848 Method 'SetFocus' of object '_Combobox' failed
  2. List Rows=3
  3. Enabled=True
  4. Visible=True
and if I step it, resumes at Line #8.

The form then seems OK, showing cboQuick with the dropdown list, but if I click an item in the list, Access closes completely, instantly. No warnings, no opportunity to save anything. Well almost completely. It does not close Help, nor does it delete the .ldb file. There is a Private Sub cboQuick_Click()
but that code is never entered.

If I click any other control except cboQuick, the dropdown does not close, it persists. It will persist even if I change to other windows, i.e. Windows Explorer.

What is going on?
Mar 5 '09 #1
16 2381
puppydogbuddy
1,923 Expert 1GB
Hi OldBirdman,

What is going on is 2 things, the first is that you are encountering an error on the set focus code line (could there be nulls returned from the combobox?), and the second is that your code is terminating because the statement following Resume Next is End Sub.

To reiterate: Your code is encountering an error on line 7 (SetFocus), then the error is passed to the error handler. The error handling code is executed, resulting in the program execution being halted at line 15 when the Stop statement is executed. Then the resume next is executed , the next code line is the end sub.
Mar 5 '09 #2
OldBirdman
675 512MB
If error is ignored, and subroutine called again, Line #7 errors and the Debug.Print is
Expand|Select|Wrap|Line Numbers
  1. List Rows=4
  2. Enabled=True
  3. Visible=True
  4. -2147417848 Automation error
  5. The object invoked has disconnected from its clients. 
How can I have an "Automation error" with an object on the current form?
Mar 5 '09 #3
OldBirdman
675 512MB
Thanks for responding, puppydogbuddy. I missed this earlier as I was adding information with a simultaneous post to yours.

...first is that you are encountering an error on the set focus code line
Yes, I would agree with this.

could there be nulls returned from the combobox?
No, but even if there were, this is a .SetFocus to a control on the current form. The only reason it isn't Me.cboQuick.SetFocus is Me. can only be used in a Class Module.

...and the second is that your code is terminating because the statement following Resume Next is End Sub.
The code executes (at least when stepped) as Line 4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 8, 9. Why would Resume Next, which is essentially a GoTo Line 11 not execute if followed by an End Sub? Removing Line 15 still displays the .DropDown, so the Stop doesn't affect the execution order.

resulting in the program execution being halted at line 15 when the Stop statement is executed.
When I say that Access closes, I don't mean the code is paused at a Stop Statement, I mean that the VBA Window closes, all my open forms close, the DataBase Window closes, the Access Window closes, and if I didn't have Windows Internet Explorer open, all I would see is my desktop image. No "Do you want to save?" msgbox. Restarting Access shows that the last access file in the filelist is not the one just closed.
Although Help is not closed with the rest of Access, it will take a computer re-boot to allow me to type in the Answer Wizard boxes or the Index Enter Keyword box.
Mar 6 '09 #4
RuralGuy
375 Expert 256MB
It may help to understand that errors in Access tend to invalidate Global Variables. Can you just comment out line 7 and have it function correctly? I do not believe the DropDown function requires the control to have the focus.
Mar 6 '09 #5
missinglinq
3,532 Expert 2GB
Afraid it does, Allan!

Linq ;0)>.
Mar 6 '09 #6
puppydogbuddy
1,923 Expert 1GB
Hi OldBirdman,
I was not thinking. You are correct about the Resume Next statement.... If the error occurred in the same procedure as the error handler, execution resumes with the statement immediately following the statement that caused the error. If the error occurred in a called procedure, execution resumes with the statement immediately following the statement that last called out of the procedure containing the error-handling routine (or On Error Resume Next statement).

In light of the above, the error occurs on line #7 (SetFocus error), it should resume next at line #8 (the dropdown statement). However, it can't resume at line #8 because the dropdown statement requires a setFocus on the combobox as Linq already stated. I believe this stalemate is what triggers Access to close. The only thing left to figure out is why you are getting the setFocus error on the combobox.
Mar 6 '09 #7
RuralGuy
375 Expert 256MB
@missinglinq
I am now wiser, kind sir.
Mar 6 '09 #8
Stewart Ross
2,545 Expert Mod 2GB
Hi OB. I've not found anything on MSDN about error -2147417848 in an Access context; there are some knowledge base articles relating to command bars or the like, but none at all for the circumstances you mention.

However, there are references to error -2147417848 arising in the context of disconnection from automation objects (although in other applications). There is no one cause, but clashes between instances of installed OCX controls is mentioned in some cases.

I also found a knowledge base article specific to VB 5 and 6 forms (not Access or VBA) which describes that particular error occurring after a setfocus issue, the context being form controls passed as parameters outside the scope of current projects, but again this does not relate to your current circumstances.

As Access is crashing altogether, and none of us can reproduce the problem on our installations, it may be that you have some kind of clash between installed components in your installation, or perhaps a corrupt database of some kind, which is killing the application in circumstances where normal operation should continue.

Last year I had automation disconnection errors occurring in one form of a database which had been developed incrementally over a period of many years. It had been running fine with that form for over a year, started occurring suddenly but was every time thereafter, and its cause could not be traced by normal debugging. In my case this was a sudden internal database corruption of unknown nature, resolved by reverting to a known good back-up.

In this context, 'automation disconnection' does not relate to anything we do as developers - it seems to relate to the internal built-in processing performed by controls and forms in their normal operation.

I wish I could be of more help here, but this one does seem to be one of the really inscrutable errors...

-Stewart
Mar 6 '09 #9
OldBirdman
675 512MB
Thank you all for your attention.

Some comments on your responses. I have tried this with the cboQuick.SetFocus removed, and as expected, I get
2185 You can't reference a property or method for a control unless the control has the focus.
I have Googled the '2185' error before, when the control should have the focus, such as in the OnClick for that control. There are many forums found where this is asked, and almost all of them respond that the control must not be .Enabled, .Visible, or there is a mis-spelling. I added the Debug.Print to let anyone reading my post know that this was NOT the case.

It may help to understand that errors in Access tend to invalidate Global Variables.
I have to be careful when I proceed from the Stop statement because of this. Without the Stop, Access does not loose the Global Variables, but once it shows the VB code, the Global stuff is gone. What I posted is after about 50 tests of various combinations of Stops, Resumes, and such.

I have tried this on my laptop, Access 2002 instead of Access 2000, and I get the same -2147417848 message. Both machines re-booted with nothing else running (except all that stuff like virus protection that auto-starts). I've never even tried Automation, so don't see how that is involved.

This is an older database, but one that I have been working on continually. I was initializing this cboQuick with a procedure reference. This caused continual calls to the procedure any time any control focus was changed. Slowed down the whole project.

I wrote a new routine as a new project and got it working. I cannot reproduce the error under test conditions, so I'm not surprised that you can't.

Of course I can back up to the original (working) state, and try again. It will be my 3rd try. 1st try got the "2185" message that cannot set focus at the .SetFocus and I could not get around that.
Mar 6 '09 #10
RuralGuy
375 Expert 256MB
If you put this function in the form's class module, does it then work without error?
Mar 6 '09 #11
DonRayner
489 Expert 256MB
Hi OB; What happens if you comment out lines 5 & 6?
Mar 6 '09 #12
OldBirdman
675 512MB
If you put this function in the form's class module, does it then work without error?
This will involve a considerable amount of work, as many procedures are intertwined. I've spent 3 hours at it, and I'm making it worse. Do you have some reason to believe this might be an answer? If so, I'll pursue. If you're only fishing, I really don't know.

As I said in my previous post,
I wrote a new routine as a new project and got it working. I cannot reproduce the error under test conditions, so I'm not surprised that you can't.
I'm trying now to get this closer to the actual program, by moving the procedures to from class modules.

What happens if you comment out lines 5 & 6?
There is no difference, -2147417848 Method 'SetFocus' of object '_Combobox' failed with the same values for .Enabled, .Visible, etc.
Mar 6 '09 #13
RuralGuy
375 Expert 256MB
It sounds like you are zeroing in on the solution. I'll leave you alone for now.
Mar 6 '09 #14
OldBirdman
675 512MB
I'll eventually make it go away. I just wish that there were some documentation (Microsoft should do) regarding this message. Once gone away, there is no guarantee that it will stay gone. I've had these things come back and bite me.

Thank you all for your mental efforts.
Mar 6 '09 #15
OldBirdman
675 512MB
My project needs a ComboBox (cbo) that could contain 2,500 rows, 50 bytes/row. Probably never this big, but I have to program for it. Because cbo.RowSourceType = Value List limits the length of cbo.RowSource to 2048 bytes, I chose to use a procedure to fill the rows.

This solution appeared to solve my problems, but Access continually ran the initialization procedure. Every time any control on the form, or any form in the project, changed, Access was running the initialization. I understand running enough to display to cbo.ListRows, and then finishing later, but continually?

I then came up with different logic to do the same thing, and could work with the 2048 byte limits. So I changed cbo.RowSourceType to Value List, and wrote the code to build the list and assigned it to cbo.RowSource. The results were "-2147417848 Automation error", which I became fixated on, and posted here.

After much trial-and-error, it turns out that the problem was cbo.RowSourceType = Value List, done in Design View in the properties box. Making only this change caused strange problems.

The background color of textboxes would change when the control got focus, and remain changed/wrong even after lost focus. Didn't matter bound or unbound. Comboboxes would also change color, and the item selected would not display. Bound or unbound. If bound, and moving to another record and back, the change had been made, just not displayed.

Attempting to change to Design View always terminated Access without warning.

Eventually I just deleted the cbo, saved, and exited Access. Re-entered and created a new cbo from scratch. Controls are acting as I want them to. No strange messages, no problems with SetFocus.

I know this is wordy, but I thought you would want to know.
Mar 7 '09 #16
RuralGuy
375 Expert 256MB
Thanks for posting back with your success, OldBirdman. It will help others I'm sure.
Mar 8 '09 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Tobias Langner | last post by:
compiling this line: SmartPtr<LongWrapper, RefCount> p1=SmartPtr<LongWrapper, RefCount>(new LongWrapper(1)); with SmartPtr being: template <class T, template <class> class OwnershipPolicy>...
20
by: Sam | last post by:
Hi I'm learning to code with C++ and wrote some very simple code. I think it's consistent with every rule but always got compiling errors that I don't understand. The code include 5 files as...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
10
by: Wayne Wengert | last post by:
I am using a datareader (dr1) to read through rows returned from a query. I am getting the error: "No data exists for the row/column." at the "If IsDbNull..." in the code below. The field "Photo1"...
20
by: Wes Groleau | last post by:
I was doing update statements in SQL Server 2000. I have a table with over 16 million rows. It came from several hundred delimited text files, and two of the columns are file ID (int) and Line...
8
by: Joshua Moore | last post by:
/* Hi, I was hoping someone could help me with this problem. I did my work and worked my way through the usual compiler messages, but I have run against some problem I can't identify. The compiler...
38
by: Jonathan Wood | last post by:
The following code raises the error "Specified cast is not valid." MembershipUser user = Membership.GetUser(userId); DataSet ds = DataLayer.ExecQueryData("SELECT * FROM mc_Clients WHERE...
1
by: okonita | last post by:
I need major help resolving a UDF error. My environment id DB2 UDBv8.2 and v9.1 on a Linux and Windows server. I am getting a SQL20148N error which states as follows: SQL20148N Routine...
3
by: Ben Thomas | last post by:
Hello, I have the following code which I don't understand why it works : #include <iostream> using namespace std; void DontWork (unsigned int& i) { cout << i << endl; }
0
by: Stef Mientki | last post by:
Terry Reedy wrote: sorry, don't know how this happened, as I always copy/paste ? AFAIK locals() == sys._getframe(0).f_locals AFAIK, again one level up weird, I use it in 2.5 and if I remember...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.