I have a userform with five(5) textboxes that must be filled with figures based on entry in another textbox (Me.txtAmtRemainToSplit.Text). I want to implement some checks such that if the first textbox (Me.txtSplitAmt1st.Text ) is not filled the user cannot fill the 2nd textbox. If 2nd textbox is not filled the 3rd textbox cannot be filled and so on. The figures in the textbox are used to populate cells in a range selected by user . In other words there should not be empty texbox between any entries. I have implemented the checks or controls below. When the userform initializes the 3rd texboxes to the 5th are locked or disabled. As and when the 2nd textbox is filled , the next textbox, 3rd one is enabled. The 4th textbox is enabled the same way, so is the 5th one . The issue is that when any of the disabled texboxes are enabled, the user may fill them and delete the entry in the 1st or 2nd texboxes. I have tried several ways to go around this but I have not found a way out. Any suggestions are welcome.
Note T1, T2, T3 etc have already been defined on top of the private module
Sub MultipleReceiptCtrl()
T1 = Val(Me.txtSplitAmt1st.Text)
T2 = Val(Me.txtSplitAmt2nd.Text)
T3 = Val(Me.txtSplitAmt3rd.Text)
T4 = Val(Me.txtSplitAmt4th.Text)
T5 = Val(Me.txtSplitAmt5th.Text)
Select Case Val(Me.txtAmtRemainToSplit.Text)
Case Is <> 0
MsgBox "Multiple Receipts must be equal to amount to Split. Remainder Must be Zero"
Me.txtSplitAmt2nd.SetFocus
Case Is = 0
If Val(Me.txtSplitAmt1st.Text) = Val(Me.txtAmtToSplit.Text) Then
MsgBox "There is no Multiple Receipts. Fill the 2nd Box"
Me.txtSplitAmt2nd.SetFocus
End If
Case Else
Select Case True
Case (T4 = "" Or T3 = "" Or T2 = "" Or T1 = "")
If T5 > 0 Then
MsgBox " The top empty box(es) should be filled before this box"
Exit Sub
End If
Case (T3 = "" Or T2 = "" Or T1 = "")
If T4 > 0 Then
MsgBox " The top empty box(es) should be filled before this box"
Exit Sub
End If
Case (T2 = "" Or T1 = "")
If T3 > 0 Then
MsgBox " The top empty box(es) should be filled before this box"
Exit Sub
End If
Case T1 = ""
If T2 > 0 Then
MsgBox " The top empty box should be filled before this box"
Exit Sub
End If
End Select
End Select
End Sub
Note T1, T2, T3 etc have already been defined on top of the private module
Sub MultipleReceiptCtrl()
T1 = Val(Me.txtSplitAmt1st.Text)
T2 = Val(Me.txtSplitAmt2nd.Text)
T3 = Val(Me.txtSplitAmt3rd.Text)
T4 = Val(Me.txtSplitAmt4th.Text)
T5 = Val(Me.txtSplitAmt5th.Text)
Select Case Val(Me.txtAmtRemainToSplit.Text)
Case Is <> 0
MsgBox "Multiple Receipts must be equal to amount to Split. Remainder Must be Zero"
Me.txtSplitAmt2nd.SetFocus
Case Is = 0
If Val(Me.txtSplitAmt1st.Text) = Val(Me.txtAmtToSplit.Text) Then
MsgBox "There is no Multiple Receipts. Fill the 2nd Box"
Me.txtSplitAmt2nd.SetFocus
End If
Case Else
Select Case True
Case (T4 = "" Or T3 = "" Or T2 = "" Or T1 = "")
If T5 > 0 Then
MsgBox " The top empty box(es) should be filled before this box"
Exit Sub
End If
Case (T3 = "" Or T2 = "" Or T1 = "")
If T4 > 0 Then
MsgBox " The top empty box(es) should be filled before this box"
Exit Sub
End If
Case (T2 = "" Or T1 = "")
If T3 > 0 Then
MsgBox " The top empty box(es) should be filled before this box"
Exit Sub
End If
Case T1 = ""
If T2 > 0 Then
MsgBox " The top empty box should be filled before this box"
Exit Sub
End If
End Select
End Select
End Sub