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]
The Clearall function that is called is:
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?
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