Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Clear Form results in INCORRECT "Invalid Property" message....
Hi - my code works fine if youve just open the app. But if I clear the
form I and start again it sends up Invalid property messages IN ERROR. The entries in these field are correct. Could someone check my code and tell me where I have gone wrong? Thanks Bernie |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Clear Form results in INCORRECT "Invalid Property" message....
Far to long to check.
Do you have a *short* version? Comment everything out which is not *relevant*. Tim "B" wrote in message ups.com... Option Explicit <snipped 2000 lines of code.... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Clear Form results in INCORRECT "Invalid Property" message....
yes I see....I just have no idea where the problem is coming from so I
just posted it all. I can email the file if your like! :) This is the "Clear Form" bit....cant see anything harmful there.... Private Sub cmdClearUF_Click() 'Clear all fields on the form. 'Shared fields cbxAge = "" cbxSex = "" cbxState = "" cbxNoH = "" 'Income Protection tbxOcCat = "" cbxOcCat = "" tbxSal = "" tbxWkBenN = "" tbxWkBenS = "" tbxWkBenT = "" tbxAnPrem = "" tbxWkPrem = "" tbxAnPremSD = "" tbxWkPremSD = "" tbxNoUIP = "" tbxEligible = "" 'cbxOcCat.Locked = False 'tbxSal.Locked = False 'Death/TPD Frame 'cbxNoUDT.Locked = False 'cbxSIDT.Locked = False cbxNoUDO = "" cbxNoUDT = "" cbxSIDO = "" cbxSIDT = "" tbxDOAnPrem = "" tbxDOWkPrem = "" tbxDTAnPrem = "" tbxDTWkPrem = "" tbxUValDO = "" tbxUValDT = "" tbxTPDDef = "" tbxSumAnPrem = "" tbxSumWkPrem = "" tickDO = False tickDT = False tickIP = False cbxSex.Locked = True cbxState.Locked = True cbxNoH.Locked = True cbxNoUDO.Locked = True cbxNoUDT.Locked = True cbxSIDO.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True ' Here is the bit that gets calculated when the age is specified Private Sub cbxAge_Change() 'Unlocks these boxes 'When changing age clears these frames. cbxSex = "" cbxState = "" cbxNoH = "" 'Income Protection cbxOcCat = "" tbxSal = "" tbxWkBenN = "" tbxWkBenS = "" tbxWkBenT = "" tbxAnPrem = "" tbxWkPrem = "" tbxAnPremSD = "" tbxWkPremSD = "" tbxNoUIP = "" tbxEligible = "" 'Death Only And Death & TPD cbxNoUDO = "" cbxNoUDT = "" cbxSIDO = "" cbxSIDT = "" tbxDOAnPrem = "" tbxDOWkPrem = "" tbxDTAnPrem = "" tbxDTWkPrem = "" tbxUValDO = "" tbxUValDT = "" tbxTPDDef = "" If cbxAge < "" Then cbxSex.Locked = False cbxState.Locked = True cbxNoUDO.Locked = True cbxNoUDT.Locked = True cbxSIDO.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True End If If (cbxAge < 18) Then tbxEligible = "Insurance is not available to members uner 18 years of age." cbxSex.Locked = True cbxState.Locked = True cbxNoUDO.Locked = True cbxNoUDT.Locked = True cbxSIDO.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True GoTo Label2 If (cbxAge < 65) Then If cbxNoH < "" Then 'cbxNoH.Locked = False cbxNoUDT.Locked = False cbxSIDT.Locked = False cbxOcCat.Locked = False tbxSal.Locked = False End If End If If (cbxAge 69) Then tbxEligible = "Insurance is not available to members over 69 years of age." cbxNoUDO = "NA" cbxSIDO = "NA" cbxNoUDT = "NA" cbxSIDT = "NA" tbxSal = "NA" tickIP = False tickDT = False tickDO = False cbxSex.Locked = True cbxState.Locked = True cbxNoUDO.Locked = True cbxSIDO.Locked = True cbxNoUDT.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True cbxOcCat.Locked = True cmdLookUp.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True GoTo Label2 End If End If 'If over 65 shows that Death&TPD and IP not available. If (cbxAge 64) Then cbxNoUDT = "NA" cbxSIDT = "NA" tbxDTAnPrem = "NA" tbxDTWkPrem = "NA" tbxUValDT = "NA" tbxTPDDef = "Death & TPD Insurance not available to persons 65 or over." cbxOcCat = "NA" tbxSal = "NA" tbxWkBenN = "NA" tbxWkBenS = "NA" tbxWkBenT = "NA" tbxAnPrem = "NA" tbxWkPrem = "NA" tbxAnPremSD = "NA" tbxWkPremSD = "NA" tbxNoUIP = "NA" tbxEligible = "Income Protection Insurance not available to persons 65 or over" cbxNoH.Locked = True cbxNoUDT.Locked = True cbxSIDT.Locked = True cbxOcCat.Locked = True tbxSal.Locked = True End If 'If AGE changed this finds relevant cells for Sum Insured, Unit Value for age. If cbxAge < "" Then sheetA = "=DTArrays!" sheetB = "DTArrays" Select Case cbxAge Case Is <= 29 valueCellDT = "B" Case Is <= 34 valueCellDT = "C" Case Is <= 39 valueCellDT = "D" Case Is <= 44 valueCellDT = "E" Case Is <= 49 valueCellDT = "F" Case Is <= 54 valueCellDT = "G" Case Is <= 59 valueCellDT = "H" Case Is <= 64 valueCellDT = "I" Case Else GoTo Label1 End Select NoUDT = 0 SIDT = 0 rangeDT = valueCellDT & "3" Do Until SIDT 1000001 NoUDT = NoUDT + 1 SIDT = NoUDT * Worksheets(sheetB).Range(rangeDT).Value Loop NoUDT = NoUDT + 2 sDT = NoUDT rangeSIDT = valueCellDT & "4:" & valueCellDT & sDT rangeNoUDT = "A4:" & valueCellDT & sDT cbxSIDT.RowSource = sheetA & rangeSIDT cbxNoUDT.RowSource = sheetA & rangeNoUDT valueAmtDT = FormatCurrency((Worksheets(sheetB).Range(rangeDT). Value), 0) tbxUValDT = FormatCurrency((valueAmtDT), 0) Label1: sheetC = "=DArrays!" sheetD = "DArrays" Select Case cbxAge Case Is <= 29 valueCellD = "B" Case Is <= 34 valueCellD = "C" Case Is <= 39 valueCellD = "D" Case Is <= 44 valueCellD = "E" Case Is <= 49 valueCellD = "F" Case Is <= 54 valueCellD = "G" Case Is <= 59 valueCellD = "H" Case Is <= 64 valueCellD = "I" Case Else valueCellD = "J" End Select NoUD = 0 SID = 0 rangeD = valueCellD & "3" Do Until SID 1000001 NoUD = NoUD + 1 SID = NoUD * Worksheets(sheetD).Range(rangeD).Value Loop NoUD = NoUD + 2 SD = NoUD rangeSID = valueCellD & "4:" & valueCellD & SD rangeNoUD = "A4:" & valueCellD & SD cbxSIDO.RowSource = sheetC & rangeSID cbxNoUDO.RowSource = sheetC & rangeNoUD valueAmtD = FormatCurrency((Worksheets(sheetD).Range(rangeD).V alue), 0) tbxUValDO = FormatCurrency((valueAmtD), 0) End If Label2: End Sub 'Here is one of the bits that uses the above variables and is what should happen instead of the error. 'There are 4 similar bits like this. Private Sub cbxSIDO_Change() 'Calcs premium and recalcs relevant totals if DEATH ONLY SUM INSURED AMOUNT changed. If cbxSIDO < "" Then cbxNoUDO = cbxSIDO / valueAmtD tbxDOAnPrem = FormatCurrency((((cbxNoUDO * ufAdmin.tbxAdminDOPrem.Value) * 52)), 0) tbxDOWkPrem = FormatCurrency((cbxNoUDO * ufAdmin.tbxAdminDOPrem.Value), 0) Dim VtbxDTAnPrem As Double Dim VtbxAnPremSD As Double Dim VtbxDTWkPrem As Double Dim VtbxWkPremSD As Double Dim VtbxDOAnPrem As Double Dim VtbxDOWkPrem As Double If IsNumeric(tbxDOAnPrem) = True Then VtbxDOAnPrem = tbxDOAnPrem Else: VtbxDOAnPrem = 0 End If If IsNumeric(tbxDOWkPrem) = True Then VtbxDOWkPrem = tbxDOWkPrem Else: VtbxDOWkPrem = 0 End If If IsNumeric(tbxDTAnPrem) = True Then VtbxDTAnPrem = tbxDTAnPrem Else: VtbxDTAnPrem = 0 End If If IsNumeric(tbxDTWkPrem) = True Then VtbxDTWkPrem = tbxDTWkPrem Else: VtbxDTWkPrem = 0 End If If IsNumeric(tbxWkPremSD) = True Then VtbxWkPremSD = tbxWkPremSD Else: VtbxWkPremSD = 0 End If If IsNumeric(tbxAnPremSD) = True Then VtbxAnPremSD = tbxAnPremSD Else: VtbxAnPremSD = 0 End If If tickDT = True Then tickDO = False If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem + VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem + VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem), 2) End If If tickDT = False Then If tickDO = False Then If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = "" tbxSumWkPrem = "" End If End If If tickDT = False Then If tickDO = True Then If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem + VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem + VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem), 2) tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem), 2) End If End If End If 'If tickDO = True Then tickDT = False ' If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem + VtbxAnPremSD), 2) ' tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem + VtbxWkPremSD), 2) ' If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem), 2) ' tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem), 2) If tickDO = False Then If tickDT = True Then If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem + VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem + VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem), 2) End If End If End If End If labelF: If tickDT = True Then tickDO = False End If If cbxSIDO = "" Then cbxNoUDO = "" tbxDOAnPrem = "" tbxDOWkPrem = "" End If End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Clear Form results in INCORRECT "Invalid Property" message....
You could try not relying on default properties and specifying them explicitly instead.
Eg. not tbxWkBenS = "" but tbxWkBenS.Text = "" That may reveal your problem etc. -- Tim Williams Palo Alto, CA "B" wrote in message oups.com... yes I see....I just have no idea where the problem is coming from so I just posted it all. I can email the file if your like! :) This is the "Clear Form" bit....cant see anything harmful there.... Private Sub cmdClearUF_Click() 'Clear all fields on the form. 'Shared fields cbxAge = "" cbxSex = "" cbxState = "" cbxNoH = "" 'Income Protection tbxOcCat = "" cbxOcCat = "" tbxSal = "" tbxWkBenN = "" tbxWkBenS = "" tbxWkBenT = "" tbxAnPrem = "" tbxWkPrem = "" tbxAnPremSD = "" tbxWkPremSD = "" tbxNoUIP = "" tbxEligible = "" 'cbxOcCat.Locked = False 'tbxSal.Locked = False 'Death/TPD Frame 'cbxNoUDT.Locked = False 'cbxSIDT.Locked = False cbxNoUDO = "" cbxNoUDT = "" cbxSIDO = "" cbxSIDT = "" tbxDOAnPrem = "" tbxDOWkPrem = "" tbxDTAnPrem = "" tbxDTWkPrem = "" tbxUValDO = "" tbxUValDT = "" tbxTPDDef = "" tbxSumAnPrem = "" tbxSumWkPrem = "" tickDO = False tickDT = False tickIP = False cbxSex.Locked = True cbxState.Locked = True cbxNoH.Locked = True cbxNoUDO.Locked = True cbxNoUDT.Locked = True cbxSIDO.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True ' Here is the bit that gets calculated when the age is specified Private Sub cbxAge_Change() 'Unlocks these boxes 'When changing age clears these frames. cbxSex = "" cbxState = "" cbxNoH = "" 'Income Protection cbxOcCat = "" tbxSal = "" tbxWkBenN = "" tbxWkBenS = "" tbxWkBenT = "" tbxAnPrem = "" tbxWkPrem = "" tbxAnPremSD = "" tbxWkPremSD = "" tbxNoUIP = "" tbxEligible = "" 'Death Only And Death & TPD cbxNoUDO = "" cbxNoUDT = "" cbxSIDO = "" cbxSIDT = "" tbxDOAnPrem = "" tbxDOWkPrem = "" tbxDTAnPrem = "" tbxDTWkPrem = "" tbxUValDO = "" tbxUValDT = "" tbxTPDDef = "" If cbxAge < "" Then cbxSex.Locked = False cbxState.Locked = True cbxNoUDO.Locked = True cbxNoUDT.Locked = True cbxSIDO.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True End If If (cbxAge < 18) Then tbxEligible = "Insurance is not available to members uner 18 years of age." cbxSex.Locked = True cbxState.Locked = True cbxNoUDO.Locked = True cbxNoUDT.Locked = True cbxSIDO.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True GoTo Label2 If (cbxAge < 65) Then If cbxNoH < "" Then 'cbxNoH.Locked = False cbxNoUDT.Locked = False cbxSIDT.Locked = False cbxOcCat.Locked = False tbxSal.Locked = False End If End If If (cbxAge 69) Then tbxEligible = "Insurance is not available to members over 69 years of age." cbxNoUDO = "NA" cbxSIDO = "NA" cbxNoUDT = "NA" cbxSIDT = "NA" tbxSal = "NA" tickIP = False tickDT = False tickDO = False cbxSex.Locked = True cbxState.Locked = True cbxNoUDO.Locked = True cbxSIDO.Locked = True cbxNoUDT.Locked = True cbxSIDT.Locked = True tbxSal.Locked = True cbxOcCat.Locked = True cmdLookUp.Locked = True tickIP.Locked = True tickDO.Locked = True tickDT.Locked = True GoTo Label2 End If End If 'If over 65 shows that Death&TPD and IP not available. If (cbxAge 64) Then cbxNoUDT = "NA" cbxSIDT = "NA" tbxDTAnPrem = "NA" tbxDTWkPrem = "NA" tbxUValDT = "NA" tbxTPDDef = "Death & TPD Insurance not available to persons 65 or over." cbxOcCat = "NA" tbxSal = "NA" tbxWkBenN = "NA" tbxWkBenS = "NA" tbxWkBenT = "NA" tbxAnPrem = "NA" tbxWkPrem = "NA" tbxAnPremSD = "NA" tbxWkPremSD = "NA" tbxNoUIP = "NA" tbxEligible = "Income Protection Insurance not available to persons 65 or over" cbxNoH.Locked = True cbxNoUDT.Locked = True cbxSIDT.Locked = True cbxOcCat.Locked = True tbxSal.Locked = True End If 'If AGE changed this finds relevant cells for Sum Insured, Unit Value for age. If cbxAge < "" Then sheetA = "=DTArrays!" sheetB = "DTArrays" Select Case cbxAge Case Is <= 29 valueCellDT = "B" Case Is <= 34 valueCellDT = "C" Case Is <= 39 valueCellDT = "D" Case Is <= 44 valueCellDT = "E" Case Is <= 49 valueCellDT = "F" Case Is <= 54 valueCellDT = "G" Case Is <= 59 valueCellDT = "H" Case Is <= 64 valueCellDT = "I" Case Else GoTo Label1 End Select NoUDT = 0 SIDT = 0 rangeDT = valueCellDT & "3" Do Until SIDT 1000001 NoUDT = NoUDT + 1 SIDT = NoUDT * Worksheets(sheetB).Range(rangeDT).Value Loop NoUDT = NoUDT + 2 sDT = NoUDT rangeSIDT = valueCellDT & "4:" & valueCellDT & sDT rangeNoUDT = "A4:" & valueCellDT & sDT cbxSIDT.RowSource = sheetA & rangeSIDT cbxNoUDT.RowSource = sheetA & rangeNoUDT valueAmtDT = FormatCurrency((Worksheets(sheetB).Range(rangeDT). Value), 0) tbxUValDT = FormatCurrency((valueAmtDT), 0) Label1: sheetC = "=DArrays!" sheetD = "DArrays" Select Case cbxAge Case Is <= 29 valueCellD = "B" Case Is <= 34 valueCellD = "C" Case Is <= 39 valueCellD = "D" Case Is <= 44 valueCellD = "E" Case Is <= 49 valueCellD = "F" Case Is <= 54 valueCellD = "G" Case Is <= 59 valueCellD = "H" Case Is <= 64 valueCellD = "I" Case Else valueCellD = "J" End Select NoUD = 0 SID = 0 rangeD = valueCellD & "3" Do Until SID 1000001 NoUD = NoUD + 1 SID = NoUD * Worksheets(sheetD).Range(rangeD).Value Loop NoUD = NoUD + 2 SD = NoUD rangeSID = valueCellD & "4:" & valueCellD & SD rangeNoUD = "A4:" & valueCellD & SD cbxSIDO.RowSource = sheetC & rangeSID cbxNoUDO.RowSource = sheetC & rangeNoUD valueAmtD = FormatCurrency((Worksheets(sheetD).Range(rangeD).V alue), 0) tbxUValDO = FormatCurrency((valueAmtD), 0) End If Label2: End Sub 'Here is one of the bits that uses the above variables and is what should happen instead of the error. 'There are 4 similar bits like this. Private Sub cbxSIDO_Change() 'Calcs premium and recalcs relevant totals if DEATH ONLY SUM INSURED AMOUNT changed. If cbxSIDO < "" Then cbxNoUDO = cbxSIDO / valueAmtD tbxDOAnPrem = FormatCurrency((((cbxNoUDO * ufAdmin.tbxAdminDOPrem.Value) * 52)), 0) tbxDOWkPrem = FormatCurrency((cbxNoUDO * ufAdmin.tbxAdminDOPrem.Value), 0) Dim VtbxDTAnPrem As Double Dim VtbxAnPremSD As Double Dim VtbxDTWkPrem As Double Dim VtbxWkPremSD As Double Dim VtbxDOAnPrem As Double Dim VtbxDOWkPrem As Double If IsNumeric(tbxDOAnPrem) = True Then VtbxDOAnPrem = tbxDOAnPrem Else: VtbxDOAnPrem = 0 End If If IsNumeric(tbxDOWkPrem) = True Then VtbxDOWkPrem = tbxDOWkPrem Else: VtbxDOWkPrem = 0 End If If IsNumeric(tbxDTAnPrem) = True Then VtbxDTAnPrem = tbxDTAnPrem Else: VtbxDTAnPrem = 0 End If If IsNumeric(tbxDTWkPrem) = True Then VtbxDTWkPrem = tbxDTWkPrem Else: VtbxDTWkPrem = 0 End If If IsNumeric(tbxWkPremSD) = True Then VtbxWkPremSD = tbxWkPremSD Else: VtbxWkPremSD = 0 End If If IsNumeric(tbxAnPremSD) = True Then VtbxAnPremSD = tbxAnPremSD Else: VtbxAnPremSD = 0 End If If tickDT = True Then tickDO = False If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem + VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem + VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem), 2) End If If tickDT = False Then If tickDO = False Then If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = "" tbxSumWkPrem = "" End If End If If tickDT = False Then If tickDO = True Then If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem + VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem + VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem), 2) tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem), 2) End If End If End If 'If tickDO = True Then tickDT = False ' If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem + VtbxAnPremSD), 2) ' tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem + VtbxWkPremSD), 2) ' If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDOAnPrem), 2) ' tbxSumWkPrem = FormatCurrency((VtbxDOWkPrem), 2) If tickDO = False Then If tickDT = True Then If tickIP = True Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem + VtbxAnPremSD), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem + VtbxWkPremSD), 2) End If If tickIP = False Then tbxSumAnPrem = FormatCurrency((VtbxDTAnPrem), 2) tbxSumWkPrem = FormatCurrency((VtbxDTWkPrem), 2) End If End If End If End If labelF: If tickDT = True Then tickDO = False End If If cbxSIDO = "" Then cbxNoUDO = "" tbxDOAnPrem = "" tbxDOWkPrem = "" End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
"Invalid property" after "Clear Form" | Excel Programming | |||
MsgBox "Invalid property value" | Excel Programming | |||
Crappy message when using the "recipients" property | Excel Programming | |||
Multiple "Range" with "Cells" property? | Excel Programming | |||
Multiple "Range" with "Cells" property? | Excel Programming |