PoggiPJ
Active Member
- Joined
- Mar 25, 2008
- Messages
- 330
I have an Excel 2003 userForm (Win XP) that will sometimes cause my entire Excel session to vanish or disappear sometime during the Initialize or Activate event. No Runtime Error, No warning,. nothing. It's a very straght forward multi-page form, and the initialize basically contains a bunch of assignment statements.
The only thing I can suspect is that I'm getting caught in some kind of recursive loop. Any ideas?
The only thing I can suspect is that I'm getting caught in some kind of recursive loop. Any ideas?
Code:
'Form Change History
'07-Feb-2012, R18-002, Displayed File Name
'20-Jan-2012, DM47, R18, Added override logic for all zOTC anniversary Periods
'21-Nov-2011, DM39, R18, added checkbox for PA periods override
'11-Nov-2011, DM169, R17, proc:custSROPlanRate_afterupdate() added CDBL (Convert to Double Precision to accommodate switching between European and US regional settings
'11-Nov-2011, DM169, R17, proc:custPACurrencyFactorBox_afterupdate() added CDBL (Convert to Double Precision to accommodate switching between European and US regional settings
'28-Sep-2011, DM71, R17, proc:UserForm_Initialize() add MLC End Date field
'28-Sep-2011, DM71, R17, proc:UserForm_Activate() add MLC End Date field
'28-Sep-2011, DM71, R17, proc:DealHasMLC_Click() add MLC End Date field
'16-Aug-2011, DM141, R17, proc:PlanRate_afterupdate, enable override of plan rate with spot rate when plan rate value = 0
Private Sub UserForm_Initialize()
'Blank dates will trigger an error so replace any critical blank dates with the current system date
'Procedure Change History
'28-Sept-2011, DM71, Add Separate MLC End Date
Debug.Print "Initialize"
Dim PriorCalculationState As Long
'Turn off Application Event handling so that loading the form does not trigger edits
HoldApplicationEvents
OCP_Hold = True
Application.StatusBar = "Populating Opportunity Control Panel"
'Pickup data from the Customer Data worksheet, and display it on the Customer Information Panel
On Error GoTo 0
'R18-002, Pick up and Display File Name
Opportunity_Form.lblFileName = ActiveWorkbook.Name
Opportunity_Form.OTCStartDateBox.Value = Customer_Data.Range("custOTCPurchDate").Value
'28-Sept-2011, DM71, R17, Add separate MLC End Date
Opportunity_Form.MLCEndDateBox.Value = Customer_Data.Range("custMLCEndDate").Value
Opportunity_Form.MLCStartDateBox.Value = Customer_Data.Range("custMLCStartDate").Value
Opportunity_Form.ContractEndDateBox.Value = Customer_Data.Range("custContractEndDate").Value
Opportunity_Form.MLCDurationDisplayBox = Customer_Data.Range("custMLCDuration").Value
Opportunity_Form.MLC1stPerBox.Value = Customer_Data.Range("custMLC1stPeriod").Value
'-------------------------------------------------------------------------
'
' Load the Default and Override Alternate Anniversary page
'
'-------------------------------------------------------------------------
'ANNIVERSARIES
'Initially display the default anniversaries as months-per-period
'09-Jan-2012, DM47, R18, Manual override OTC Months Per Period for zOTC
'21-Nov-2011, DM47, R18, Manual override OTC Months Per Period
'21-Nov-2011, DM39, R18, PA Autobuild, override periods
'Display PA Durations per period data
Opportunity_Form.custPADefP1 = Customer_Data.Range("cust_pa_def_P1")
Opportunity_Form.custPADefP2 = Customer_Data.Range("cust_pa_def_P2")
Opportunity_Form.custPADefP3 = Customer_Data.Range("cust_pa_def_P3")
Opportunity_Form.custPADefP4 = Customer_Data.Range("cust_pa_def_P4")
Opportunity_Form.custPADefP5 = Customer_Data.Range("cust_pa_def_P5")
Opportunity_Form.custPADefP6 = Customer_Data.Range("cust_pa_def_P6")
'Display latest PA override anniversaries and selection check box
Opportunity_Form.cbPAOverride = Customer_Data.Range("custPAPeriodOverride")
Opportunity_Form.custPAOvRP1 = Customer_Data.Range("cust_pa_ovr_P1")
Opportunity_Form.custPAOvRP2 = Customer_Data.Range("cust_pa_ovr_P2")
Opportunity_Form.custPAOvRP3 = Customer_Data.Range("cust_pa_ovr_P3")
Opportunity_Form.custPAOvRP4 = Customer_Data.Range("cust_pa_ovr_P4")
Opportunity_Form.custPAOvRP5 = Customer_Data.Range("cust_pa_ovr_P5")
Opportunity_Form.custPAOvRP6 = Customer_Data.Range("cust_pa_ovr_P6")
'Display zOTC Default Durations
Opportunity_Form.custzotcDefP1 = Customer_Data.Range("cust_zOTC_def_P1")
Opportunity_Form.custzotcDefP2 = Customer_Data.Range("cust_zOTC_def_P2")
Opportunity_Form.custzotcDefP3 = Customer_Data.Range("cust_zOTC_def_P3")
Opportunity_Form.custzotcDefP4 = Customer_Data.Range("cust_zOTC_def_P4")
Opportunity_Form.custzotcDefP5 = Customer_Data.Range("cust_zOTC_def_P5")
Opportunity_Form.custzotcDefP6 = Customer_Data.Range("cust_zOTC_def_P6")
'Display latest zOTC override anniversaries and selection check box
Opportunity_Form.cbzOTCOverride = Customer_Data.Range("custzOTCPeriodOverride")
Opportunity_Form.custzOTCOvRP1 = Customer_Data.Range("cust_zOTC_ovr_P1")
Opportunity_Form.custzOTCOvRP2 = Customer_Data.Range("cust_zOTC_Ovr_P2")
Opportunity_Form.custzOTCOvRP3 = Customer_Data.Range("cust_zOTC_Ovr_P3")
Opportunity_Form.custzOTCOvRP4 = Customer_Data.Range("cust_zOTC_Ovr_P4")
Opportunity_Form.custzOTCOvRP5 = Customer_Data.Range("cust_zOTC_Ovr_P5")
Opportunity_Form.custzOTCOvRP6 = Customer_Data.Range("cust_zOTC_Ovr_P6")
'Display FCT Default Durations
Opportunity_Form.custFCTDefP1 = Customer_Data.Range("cust_FCT_def_P1")
Opportunity_Form.custFCTDefP2 = Customer_Data.Range("cust_FCT_def_P2")
Opportunity_Form.custFCTDefP3 = Customer_Data.Range("cust_FCT_def_P3")
Opportunity_Form.custFCTDefP4 = Customer_Data.Range("cust_FCT_def_P4")
Opportunity_Form.custFCTDefP5 = Customer_Data.Range("cust_FCT_def_P5")
Opportunity_Form.custFCTDefP6 = Customer_Data.Range("cust_FCT_def_P6")
'Display latest FCT override anniversaries and selection check box
Opportunity_Form.cbFCTOverride = Customer_Data.Range("custFCTPeriodOverride")
Opportunity_Form.custFCTOvRP1 = Customer_Data.Range("cust_FCT_ovr_P1")
Opportunity_Form.custFCTOvRP2 = Customer_Data.Range("cust_FCT_Ovr_P2")
Opportunity_Form.custFCTOvRP3 = Customer_Data.Range("cust_FCT_Ovr_P3")
Opportunity_Form.custFCTOvRP4 = Customer_Data.Range("cust_FCT_Ovr_P4")
Opportunity_Form.custFCTOvRP5 = Customer_Data.Range("cust_FCT_Ovr_P5")
Opportunity_Form.custFCTOvRP6 = Customer_Data.Range("cust_FCT_Ovr_P6")
'--------------------------------------------------------------------------------------
'
' Load the Customer Information page
'
'--------------------------------------------------------------------------------------
Opportunity_Form.cbOCPDisplayOnOpen.Value = Configuration.Range("cfgDisplayOppCtrlPnl")
'Display Customer Information Section
Opportunity_Form.customerNameBox.Value = Customer_Data.Range("custName").Value
Opportunity_Form.custShortDescBox.Value = Customer_Data.Range("custShortDesc").Value
Opportunity_Form.custStreetBox.Value = Customer_Data.Range("custStreet").Value
Opportunity_Form.custCityBox.Value = Customer_Data.Range("custCity").Value
Opportunity_Form.custStateBox.Value = Customer_Data.Range("custState").Value
Opportunity_Form.custPostalCodeBox.Value = Customer_Data.Range("custPostalCode").Value
'Display Location Information
Opportunity_Form.selectGeo.Value = Customer_Data.Range("custGeo").Value
Opportunity_Form.selectRegion.Value = Customer_Data.Range("region").Value
Opportunity_Form.selectCountry.Value = Customer_Data.Range("custCountry").Value
'Display Local Uplift Entries
'DM172, Changed from Value to Text to preserve european formatting _
This is for display only - values are updated dynamically upon any change
Opportunity_Form.custPACurrencyFactorBox.Text = CDbl(Customer_Data.Range("custPACurrencyFactor").Text)
Opportunity_Form.custPACurrencyNameBox.Value = Customer_Data.Range("custPACurrencyName").Value
'Display SRO Currency Selections
Opportunity_Form.PlanRate.Value = Customer_Data.Range("custSelectedPlanRate").Value
'DM172, Changed from Value to Text to preserve european formatting _
This is for display only - values are updated dynamically upon any change
Opportunity_Form.custSROPlanRate.Text = CDbl(Customer_Data.Range("custSROPlanRate").Text)
Opportunity_Form.custSROPlanCurrency.Value = Customer_Data.Range("custSROPlanCurrency").Value
'Display DSW Price File Selections
Opportunity_Form.currencyBox = Customer_Data.Range("custCurrency").Value
Opportunity_Form.currencyDateBox.Value = Format(Configuration.Range("cfgDSWPriceFileDate").Value, "dd-mmm-yyyy")
Opportunity_Form.RoyaltyDateBox.Value = Format(Configuration.Range("cfgRoyaltyFileDate").Value, "dd-mmm-yyyy")
'-------------------------------------------------------------------------------------------------------------------
'
' Load the Contacts page
'
'-------------------------------------------------------------------------------------------------------------------
'Display IBM Personnel Information Section
Opportunity_Form.dealmakerNameBox.Value = Customer_Data.Range("custNameDealmaker").Value
Opportunity_Form.phoneBoxDM.Value = Customer_Data.Range("custPhoneDM").Value
Opportunity_Form.ssrNameBox.Value = Customer_Data.Range("custNameSSR").Value
Opportunity_Form.phoneBoxSSR.Value = Customer_Data.Range("custPhoneSSR").Value
Opportunity_Form.clientexecNameBox.Value = Customer_Data.Range("custNameCE").Value
Opportunity_Form.phoneBoxCE.Value = Customer_Data.Range("custPhoneCE").Value
Opportunity_Form.WWPricingApproverNameBox.Value = Customer_Data.Range("custNameWWPA").Value
Opportunity_Form.phoneBoxWWPA.Value = Customer_Data.Range("custPhoneWWPA").Value
Opportunity_Form.SDPricingApproverNameBox = Customer_Data.Range("custNameSDPA").Value
Opportunity_Form.phoneBoxSDPA.Value = Customer_Data.Range("custPhoneSDPA").Value
Opportunity_Form.dealHubNameBox.Value = Customer_Data.Range("custNameDH").Value
Opportunity_Form.phoneBoxDH.Value = Customer_Data.Range("custPhoneDH").Value
Opportunity_Form.DealHubZNameBox.Value = Customer_Data.Range("custNameDHZ").Value
Opportunity_Form.phoneBoxDHZ.Value = Customer_Data.Range("custPhoneDHZ").Value
Opportunity_Form.DealHubPANameBox.Value = Customer_Data.Range("custNameDHPA").Value
Opportunity_Form.phoneBoxDHPA.Value = Customer_Data.Range("custPhoneDHPA").Value
'****DM96, R19, Added new contact names, titles, phones
Opportunity_Form.tbOptContactType1.Value = Customer_Data.Range("custOptContactType1").Value
Opportunity_Form.tbOptContactName1.Value = Customer_Data.Range("custOptContactName1").Value
Opportunity_Form.tbOptContactPhone1.Value = Customer_Data.Range("custOptContactPhone1").Value
Opportunity_Form.tbOptContactType2.Value = Customer_Data.Range("custOptContactType2").Value
Opportunity_Form.tbOptContactName2.Value = Customer_Data.Range("custOptContactName2").Value
Opportunity_Form.tbOptContactPhone2.Value = Customer_Data.Range("custOptContactPhone2").Value
Opportunity_Form.tbOptContactType3.Value = Customer_Data.Range("custOptContactType3").Value
Opportunity_Form.tbOptContactName3.Value = Customer_Data.Range("custOptContactName3").Value
Opportunity_Form.tbOptContactPhone3.Value = Customer_Data.Range("custOptContactPhone3").Value
'Contract Terms Panel
'Display Contract Information Section
Opportunity_Form.selectDealType.Value = Customer_Data.Range("custDealType").Value
Opportunity_Form.ProposalDateBox.Value = Format(Customer_Data.Range("DateOfProposal").Value, "dd-mmm-yyyy")
Opportunity_Form.custNumberBox.Value = Customer_Data.Range("CustomerNumber").Value
Opportunity_Form.icaContractBox.Value = Customer_Data.Range("ICAContractNumber").Value
Opportunity_Form.paContNumberBox.Value = Customer_Data.Range("custPAContractNo").Value
Opportunity_Form.tbPADefaultSite.Value = Customer_Data.Range("custPASiteNr").Value
Opportunity_Form.paBandBox.Value = Customer_Data.Range("PABandLevel").Value
Opportunity_Form.ESSOContractBox.Value = Customer_Data.Range("custESSONumber").Value
Opportunity_Form.InternalContractBox.Value = Customer_Data.Range("custInternalNumber").Value
'Display OTC S&S Terms Section
Opportunity_Form.OTC1stPerBox.Value = Customer_Data.Range("custOTC1stPeriod").Value
Opportunity_Form.OTCStartDateBox.Value = Format(Customer_Data.Range("custOTCPurchDate").Value, "dd-mmm-yyyy")
Opportunity_Form.ContractEndDateBox.Value = Format(Customer_Data.Range("custContractEndDate").Value, "dd-mmm-yyyy")
Opportunity_Form.OTCDurationDisplayBox.Caption = Customer_Data.Range("custOTCDuration").Value 'calculated in spreadsheet formula
Opportunity_Form.OTC_DurationOverride.Value = Customer_Data.Range("custOTC_DurationOverride").Value
'Display MLC Terms Section
Opportunity_Form.MLC1stPerBox.Value = Customer_Data.Range("custMLC1stPeriod").Value 'This is a duration field, not a date
Opportunity_Form.MLCDurationDisplayBox.Caption = Customer_Data.Range("custMLCDuration").Value 'calculated in spreadsheet formula
Opportunity_Form.MLCStartDateBox.Value = Format(Customer_Data.Range("custMLCStartDate").Value, "dd-mmm-yyyy")
'28-Sept-2011, DM71, R17, Add a separate MLC End Date
Opportunity_Form.MLCEndDateBox.Value = Format(Customer_Data.Range("custMLCEndDate").Value, "dd-mmm-yyyy")
If Customer_Data.Range("custMLCFlag").Value = True Then
Opportunity_Form.DealHasMLC = True
Opportunity_Form.MLCRecalcRequested.Enabled = True
If Customer_Data.Range("custMLCRecalcRequestedFlag") = True Then
Opportunity_Form.MLCRecalcRequested = True
Else
Opportunity_Form.MLCRecalcRequested = False
End If
Opportunity_Form.lblMLC1stPer.Enabled = True
Opportunity_Form.MLC1stPerBox.Enabled = True
Opportunity_Form.lblMLCMonths.Enabled = True
Opportunity_Form.lblMLCStartDate.Enabled = True
Opportunity_Form.MLCStartDateBox.Enabled = True
'28-Sept-2011, DM71, R17, Add a separate MLC End Date
Opportunity_Form.lblMLCEndDate.Enabled = True
Opportunity_Form.MLCEndDateBox.Enabled = True
Else
Opportunity_Form.DealHasMLC = False
Opportunity_Form.lblMLC1stPer.Enabled = False
Opportunity_Form.MLC1stPerBox.Enabled = False
Opportunity_Form.lblMLCMonths.Enabled = False
Opportunity_Form.lblMLCStartDate.Enabled = False
Opportunity_Form.MLCStartDateBox.Enabled = False
'28-Sept-2011, DM71, R17, Add a separate MLC End Date
Opportunity_Form.lblMLCEndDate.Enabled = False
Opportunity_Form.MLCEndDateBox.Enabled = False
End If
'Display Business Partner Information Section
Opportunity_Form.custbpNameBox.Value = Customer_Data.Range("custbpName").Value
Opportunity_Form.custbpMarginBox.Value = Customer_Data.Range("custbpMargin").Value
'Discounts Panel
Call GetDiscountRateData
'Cash Flow & Billing Panel
'Financing Section
Opportunity_Form.IGFLeaseSuppBox.Value = Customer_Data.Range("custIGFLeaseNumber").Value
If Customer_Data.Range("custFinancing") = True Then
Opportunity_Form.FinancingNoOption = False
Opportunity_Form.FinancingYesOption = True
Opportunity_Form.IGFLeaseLabel.Enabled = True
Opportunity_Form.IGFLeaseSuppBox.Enabled = True
Else
Opportunity_Form.FinancingNoOption = True
Opportunity_Form.FinancingYesOption = False
Opportunity_Form.IGFLeaseLabel.Enabled = False
Opportunity_Form.IGFLeaseSuppBox.Enabled = False
End If
'Cash Flow Section
If Customer_Data.Range("custCoTerminates") = "Standard" Then
Opportunity_Form.standardCashFlow = True
Opportunity_Form.coTermAtStart = False
Opportunity_Form.coTermAtEnd = False
Else
If Customer_Data.Range("custCoTerminates") = "Start" Then
Opportunity_Form.coTermAtStart = True
Opportunity_Form.coTermAtEnd = False
Opportunity_Form.standardCashFlow = False
Else
Opportunity_Form.coTermAtEnd = True
Opportunity_Form.coTermAtStart = False
Opportunity_Form.standardCashFlow = False
End If
End If
'MLC Billing Cycle Section
Select Case Customer_Data.Range("custMLCBillingCycle")
Case 1
'monthly billing
Opportunity_Form.MLCBillsMonthly = True
Opportunity_Form.MLCBillsQuarterly = False
Opportunity_Form.MLCBillsSemiAnnually = False
Opportunity_Form.MLCBillsAnnually = False
Case 3
'quarterly billing
Opportunity_Form.MLCBillsMonthly = False
Opportunity_Form.MLCBillsQuarterly = True
Opportunity_Form.MLCBillsSemiAnnually = False
Opportunity_Form.MLCBillsAnnually = False
Case 6
'semi-annual billing
Opportunity_Form.MLCBillsMonthly = False
Opportunity_Form.MLCBillsQuarterly = False
Opportunity_Form.MLCBillsSemiAnnually = True
Opportunity_Form.MLCBillsAnnually = False
Case 12
'annual billing
Opportunity_Form.MLCBillsMonthly = False
Opportunity_Form.MLCBillsQuarterly = False
Opportunity_Form.MLCBillsSemiAnnually = False
Opportunity_Form.MLCBillsAnnually = True
End Select
'zSeries OTC Billing Cycle Section
Select Case Customer_Data.Range("custzOTCBillingCycle")
Case 1
'monthly billing
Opportunity_Form.zOTCBillsMonthly = True
Opportunity_Form.zOTCBillsQuarterly = False
Opportunity_Form.zOTCBillsSemiAnnually = False
Opportunity_Form.zOTCBillsAnnually = False
Case 3
'quarterly billing
Opportunity_Form.zOTCBillsMonthly = False
Opportunity_Form.zOTCBillsQuarterly = True
Opportunity_Form.zOTCBillsSemiAnnually = False
Opportunity_Form.zOTCBillsAnnually = False
Case 6
'semi-annual billing
Opportunity_Form.zOTCBillsMonthly = False
Opportunity_Form.zOTCBillsQuarterly = False
Opportunity_Form.zOTCBillsSemiAnnually = True
Opportunity_Form.zOTCBillsAnnually = False
Case 12
'annual billing
Opportunity_Form.zOTCBillsMonthly = False
Opportunity_Form.zOTCBillsQuarterly = False
Opportunity_Form.zOTCBillsSemiAnnually = False
Opportunity_Form.zOTCBillsAnnually = True
End Select
'Passport Advantage OTC Billing Cycle Section
Select Case Customer_Data.Range("custPABillingCycle")
Case 1
'monthly billing
Opportunity_Form.PABillsMonthly = True
Opportunity_Form.PABillsQuarterly = False
Opportunity_Form.PABillsSemiAnnually = False
Opportunity_Form.PABillsAnnually = False
Case 3
'quarterly billing
Opportunity_Form.PABillsMonthly = False
Opportunity_Form.PABillsQuarterly = True
Opportunity_Form.PABillsSemiAnnually = False
Opportunity_Form.PABillsAnnually = False
Case 6
'semi-annual billing
Opportunity_Form.PABillsMonthly = False
Opportunity_Form.PABillsQuarterly = False
Opportunity_Form.PABillsSemiAnnually = True
Opportunity_Form.PABillsAnnually = False
Case 12
'annual billing
Opportunity_Form.PABillsMonthly = False
Opportunity_Form.PABillsQuarterly = False
Opportunity_Form.PABillsSemiAnnually = False
Opportunity_Form.PABillsAnnually = True
End Select
'Customer View Panel
'inflation factor
Opportunity_Form.custBAUInflationRateBox.Value = _
Customer_Data.Range("custBAUInflationRate").Value * 100
'Option Selection for Compounding Selection
If Customer_Data.Range("custBAUCompoundingPeriods") = 12 Then
Opportunity_Form.ObBAUAnnual = True
Opportunity_Form.ObBAUSemiAnnual = False
Else
Opportunity_Form.ObBAUAnnual = False
Opportunity_Form.ObBAUSemiAnnual = True
End If
'Option Selection for IBM Only or Customer BAU if specified
If Configuration.Range("cfgBAUPriceOption") = True Then
Opportunity_Form.BAUperCustomer.Value = True
Opportunity_Form.BAUperIBM.Value = False
Else
Opportunity_Form.BAUperCustomer.Value = False
Opportunity_Form.BAUperIBM.Value = True
End If
'Worksheets Panel
Call GetWrkshtViewSelections
'Schedules Panel
If Configuration.Range("cfgSchedulePrintStyle") = "Expanded" Then
Opportunity_Form.SchedulePrintExpanded = True
Opportunity_Form.SchedulePrintAggregated = False
Else
Opportunity_Form.SchedulePrintExpanded = False
Opportunity_Form.SchedulePrintAggregated = True
End If
If Configuration.Range("cfgConfiguredAs") = "Lite" Then
'Hide pages with references to non-applicable functions
Opportunity_Form.MultiPage1.CashFlow.Visible = False
Opportunity_Form.MultiPage1.BAU.Visible = False
Opportunity_Form.MultiPage1.schedules.Visible = False
Opportunity_Form.MultiPage1.Worksheets.Visible = False
'Hide references to SRO Exchange
Opportunity_Form.OTC_DurationOverride.Visible = False
Opportunity_Form.lblSROOverride1.Visible = False
Opportunity_Form.lblSROOverride2.Visible = False
'Hide references to MLC
Opportunity_Form.DealHasMLC.Visible = False
Opportunity_Form.MLCDurationDisplayBox.Visible = False
Opportunity_Form.MLCRecalcRequested.Visible = False
Opportunity_Form.lblMLCStartDate.Visible = False
Opportunity_Form.MLCStartDateBox.Visible = False
'DM71, R17, add MLC End Date
Opportunity_Form.lblMLCEndDate.Visible = False
Opportunity_Form.MLCEndDateBox.Visible = False
Opportunity_Form.FrMLC.Visible = False
Opportunity_Form.lblMLC1stPer.Visible = False
Opportunity_Form.MLC1stPerBox.Visible = False
Opportunity_Form.lblMLCMonths.Visible = False
'Hide non Lite worksheets
Opportunity_Form.wrkshtCompliance.Visible = False
Opportunity_Form.wrkshtDataPower.Visible = False
Opportunity_Form.wrkshtPAAppliances.Visible = False
Opportunity_Form.wrkshtISV.Visible = False
Opportunity_Form.wrkshtVendorSW.Visible = False
End If
OCP_Hold = False
Debug.Print "Initialized"
End Sub