Private Sub cmdSplitBill_Click()
'First Click
If IsNull(Me.cboOver1) = False Then
If Me.cboOver2.Visible = False Then
Me.cboOver2.Visible = True
Me.txtAmount2.Visible = True
Me.cmdSplitBill.Top = Me.cboOver2.Top
Exit Sub
End If
Else
MsgBox "You haven't filled out anything yet. Please fill out the first over-payee" _
& " and then add more if needed."
Exit Sub
End If
'Second Click
If Me.cboOver3.Visible = False Then
If Me.cboOver2 <> Me.cboOver1 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 3 Then
MsgBox "There were only two payees for this invoice. There are no more people " _
& "to choose from."
Exit Sub
End If
Me.cboOver3.Visible = True
Me.txtAmount3.Visible = True
Me.cmdSplitBill.Top = Me.cboOver3.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Third Click
If Me.cboOver4.Visible = False Then
If Me.cboOver3 <> Me.cboOver1 And Me.cboOver3 <> Me.cboOver2 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 4 Then
MsgBox "There were only three payees for this invoice. There are " _
& "no more people to choose from."
Exit Sub
End If
Me.cboOver4.Visible = True
Me.txtAmount4.Visible = True
Me.cmdSplitBill.Top = Me.cboOver4.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Fourth Click
If Me.cboOver5.Visible = False Then
If Me.cboOver4 <> Me.cboOver1 And Me.cboOver4 <> Me.cboOver2 _
And Me.cboOver4 <> Me.cboOver3 Then
If DCount("idrPaymentNumber", "qryPaymentList", "" _
& "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 5 Then
MsgBox "There were only four payees for this invoice. There are " _
& "no more people to choose from."
Exit Sub
End If
Me.cboOver5.Visible = True
Me.txtAmount5.Visible = True
Me.cmdSplitBill.Top = Me.cboOver5.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Fifth Click
If Me.cboOver6.Visible = False Then
If Me.cboOver5 <> Me.cboOver1 And Me.cboOver5 <> Me.cboOver2 _
And Me.cboOver5 <> Me.cboOver3 And Me.cboOver5 <> Me.cboOver4 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 6 Then
MsgBox "There were only five payees for this invoice. There are no more people " _
& "to choose from."
Exit Sub
End If
Me.cboOver6.Visible = True
Me.txtAmount6.Visible = True
Me.cmdSplitBill.Top = Me.cboOver6.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Sixth Click
If Me.cboOver7.Visible = False Then
If Me.cboOver6 <> Me.cboOver1 And Me.cboOver6 <> Me.cboOver2 _
And Me.cboOver6 <> Me.cboOver3 And Me.cboOver6 <> Me.cboOver4 _
And Me.cboOver6 <> Me.cboOver5 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 7 Then
MsgBox "There were only six payees for this invoice. There are no more people " _
& "to choose from."
Exit Sub
End If
Me.cboOver7.Visible = True
Me.txtAmount7.Visible = True
Me.cmdSplitBill.Top = Me.cboOver7.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Seventh Click
If Me.cboOver8.Visible = False Then
If Me.cboOver7 <> Me.cboOver1 And Me.cboOver7 <> Me.cboOver2 _
And Me.cboOver7 <> Me.cboOver3 And Me.cboOver7 <> Me.cboOver4 _
And Me.cboOver7 <> Me.cboOver5 And Me.cboOver7 <> Me.cboOver6 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 8 Then
MsgBox "There were only seven payees for this invoice. There are no more people " _
& "to choose from."
Exit Sub
End If
Me.cboOver8.Visible = True
Me.txtAmount8.Visible = True
Me.cmdSplitBill.Top = Me.cboOver8.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Eighth Click
If Me.cboOver9.Visible = False Then
If Me.cboOver8 <> Me.cboOver1 And Me.cboOver8 <> Me.cboOver2 _
And Me.cboOver8 <> Me.cboOver3 And Me.cboOver8 <> Me.cboOver4 _
And Me.cboOver8 <> Me.cboOver5 And Me.cboOver8 <> Me.cboOver6 _
And Me.cboOver8 <> Me.cboOver7 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 9 Then
MsgBox "There were only eight payees for this invoice. There are no more people " _
& "to choose from."
Exit Sub
End If
Me.cboOver9.Visible = True
Me.txtAmount9.Visible = True
Me.cmdSplitBill.Top = Me.cboOver9.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
End If
'Nineth Click
If Me.cboOver10.Visible = False Then
If Me.cboOver9 <> Me.cboOver1 And Me.cboOver9 <> Me.cboOver2 _
And Me.cboOver9 <> Me.cboOver3 And Me.cboOver9 <> Me.cboOver4 _
And Me.cboOver9 <> Me.cboOver5 And Me.cboOver9 <> Me.cboOver6 _
And Me.cboOver9 <> Me.cboOver7 And Me.cboOver9 <> Me.cboOver8 Then
If DCount("idrPaymentNumber", "qryPaymentList", "[intInvoiceID] = " & Me.txtHiddenInvoiceID) < 10 Then
MsgBox "There were only nine payees for this invoice. There are no more people " _
& "to choose from."
Exit Sub
End If
Me.cboOver10.Visible = True
Me.txtAmount10.Visible = True
Me.cmdSplitBill.Top = Me.cboOver10.Top
Exit Sub
Else
MsgBox "There are multiple refunds allocated for the same person. " _
& "Please fix this before adding another payee."
Exit Sub
End If
'Tenth Click
MsgBox "Can't split overpayment any more"
Exit Sub
End If
End Sub