-2147417848 automation error the object invoked has disconnected from its clients

spalton

Board Regular
Joined
Feb 20, 2009
Messages
125
Hi Guys,

Have a dropdown box on a Userform, that populate's various labels with data from a worksheet behind. And I'm getting the object invoked disconnected message, search around, added Option Expicit to all modules, but can't seem to find why it's doing this.

If you click it once, it works fine and you can move through the process, also if you hit my 'Reset' button it works fine. The problem comes when you change the dropdown box without resetting, and then you get the -2147417848 automation error the object invoked has disconnected from its clients message. The code for the drop down is:[h=2][/h]

Code:
Private Sub InsurerBox_AfterUpdate()
Worksheets("PricePres").Range("a5").Value = InsurerBox.Value
Worksheets("FullDetails").Range("B3").Value = InsurerBox.Value
ImportantInfo.Value = "All fields on this page MUST be read to the customer exactly as written or will result in an RF fail."
 MatrixMainForm.ImportantInfo.ForeColor = RGB(139, 26, 26)
Call Populate


Dim ctl As Control
For Each ctl In MatrixMainForm.Frame1.Controls
ctl.Visible = False




Next


Dim ctl2 As Control
For Each ctl2 In MatrixMainForm.Frame2.Controls
ctl2.Visible = False




Next
ClearAll MatrixMainForm


If MatrixMainForm.InsurerBox.Value <> "" Then


MatrixMainForm.InsurerLabel.Visible = True
MatrixMainForm.InsurerInfo.Visible = True
MatrixMainForm.CheckBox1.Visible = True


MatrixMainForm.ScriptBox1.Visible = True
End If




MatrixMainForm.ScriptBox1.ForeColor = RGB(47, 79, 79)






If Worksheets("PricePres").Range("A8").Value = "No" Then
  MatrixMainForm.ImportantInfo.Value = "This Insurer requires the FULL SCRIPT to be read due to No Web Acceptance."
MatrixMainForm.ImportantInfo.BackColor = RGB(139, 26, 26)
Else
MatrixMainForm.ImportantInfo.BackColor = RGB(256, 256, 256)
End If


MatrixMainForm.VanCourtesyLabel = Worksheets("FullDetails").Range("C12").Value
MatrixMainForm.Label150.Caption = InsurerBox.Value




End Sub

The Clearall function that is called is:

Code:
Option Explicit
 
 '---------------------------------------------------------------------------------------
 ' DateTime  : 09/05/2007 08:43
 ' DateTime  : 09/05/2007 08:43
 ' Author    : Roy Cox (royUK)
 ' Website   : click here for more examples and Excel Consulting
 ' Purpose   : Loops through controls of UserForm & clears setting
 '
 ' Disclaimer; This code is offered as is with no guarantees. You may use it in your
 '             projects but please leave this header intact.
 
 '---------------------------------------------------------------------------------------
 
 
Public Function ClearAll(frm As MSForms.UserForm) As Boolean
     ' clear out all controls
    Dim Octrl    As Control
     ' if any error occurs, just exit
    On Error GoTo ExitFunc
     
     ' loop through controls, figure out type and
     ' use appropriate method to clear it
    For Each Octrl In frm.Frame1.Controls
        Select Case TypeName(Octrl)
        Case "TextBox":  Octrl = Empty
        Case "CheckBox", "OptionButton": Octrl.Value = False
        Case "CheckBox", "OptionButton": Octrl.ForeColor = RGB(0, 0, 0)
        Case "ComboBox", "ListBox": Octrl.ListIndex = -1
        
        Case "Label": Octrl.BackColor = RGB(47, 79, 79)
Case Else:
        End Select
    Next Octrl
    
    
    For Each Octrl In frm.Frame2.Controls
        Select Case TypeName(Octrl)
        Case "TextBox":  Octrl = Empty
        Case "CheckBox", "OptionButton": Octrl.Value = False
        Case "CheckBox", "OptionButton": Octrl.ForeColor = RGB(0, 0, 0)
        Case "ComboBox", "ListBox": Octrl.ListIndex = -1
        Case "Label": Octrl.ForeColor = RGB(139, 26, 26)
        
Case Else:
        End Select
    Next Octrl
     
ExitFunc:
    Set Octrl = Nothing
    
    
End Function

but wierdly, when it crashes and I go to debug, the code that's highlighted is the initial Macro, from a Button on the worksheet to launch the userform. The line that is highlighted in Yellow is the MatrixMainForm.show line, Any ideas, it's driving me up the wall?

Code:
Sub Button1_Click()
Worksheets("Sheet3").Activate
MatrixMainForm.Show




End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
It may have to do with the "Analysis Toolpak - VBA" or possibly other add-in apparently if you uncheck them, close excel then reload excel might go away ( or reveal the true error)

if working without the add-ins try re-introducing them
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,405
Members
449,157
Latest member
mytux

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top