Automate data input with If, Elseif Statement
I am working with a access 2007 Database for a Lawn Service Company, I have everyone assigned to a Treatment program based on the number of applications to apply. e.g. Program 1= Round 1-7 Program 4 =Round 1,3,5,& 6 Program 5 =Round 1,2,3, & 6. When a customer is assignd to a program a group of fields named round 1 thru 7 are populated with yes or no based on the applications to apply E.G. Program 1 would be all yes, Program 5= round 1 yes, round 2 yes, round 3 yes , round 4 no, round 5 no, and round 6 yes. I am able to use a If, Elseif statement to automatically get access to enter the NSD(Nxt Service Date) and Nxt App No. based on the value entered in the App No Field and the Program assigned. The If, Elseif Statement works fine as long as I only skip 1 Application. This is the code entered in the On Exit property of the app no field.
Private Sub App_No_Exit(Cancel As Integer)
If [App No] = 1 And [Round 2] = True Then
[NSD] = "3/15/" & Year(Date)
ElseIf [App No] = 1 And [Round 2] = False Then
[NSD] = "5/1/" & Year(Date)
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False Then
[NSD] = "6/15/" & Year(Date)
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False And [Round 4] = False Then
[NSD] = "8/1/" & Year(Date)
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False And [Round 4] = False And [Round 5] = False Then
[NSD] = "9/15/" & Year(Date)
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False And [Round 4] = False And [Round 5] = False And [Round 6] = False Then
[NSD] = "11/1" & Year(Date)
End If
If [App No] = 1 And [Round 2] = True Then
[Nxt App No] = 2
ElseIf [App No] = 1 And [Round 2] = False Then
[Nxt App No] = 3
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False Then
[Nxt App No] = 4
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False And [Round 4] = False Then
[Nxt App No] = 5
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False And [Round 4] = False And [Round 5] = False Then
[Nxt App No] = 6
ElseIf [App No] = 1 And [Round 2] = False And [Round 3] = False And [Round 4] = False And [Round 5] = False And [Round 6] = False Then
[Nxt App No] = 7
End If