I converted an app from Access 2003 to 2010 in windows 7. All worked fine except that if the PaymentType is not selected, it should display a message that a PaymentType should be selected before proceeding further. It worked fine in old version but not in 2010. Below is the code. Can't figure out why it does not work.
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check to make sure a payment type is selected, then update
'the Paidthrough field in the Payment Table
Dim bytMonths As Byte
If PaymentType = 0 Then
DisplayMessage "You must select a payment type."
Cancel = True
Exit Sub
End If
bytMonths = YearsPaid * 13
Select Case PaymentType
Case 1, 2, 3, 4, 10, 12, 13, 14, 18, 22, 23
'If this is the first payment, set Paid Through from current date
If IsNull(PaidThrough) Or PaidThrough < Date Then
PaidThrough = DateSerial(Year(Date), Month(Date) + bytMonths, 1)
PaymentType = PaymentType
Else
'Otherwise, add additional months to the PaidThrough value.
PaidThrough = DateSerial(Year(PaidThrough), Month(PaidThrough) + _
bytMonths, 1)
PaymentType = PaymentType
End If
Case 5, 6, 7, 8, 9, 11, 15, 16, 17, 19, 20, 21, 24, 25, 26
Exit Sub
Case Else
End Select
Exit Sub
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check to make sure a payment type is selected, then update
'the Paidthrough field in the Payment Table
Dim bytMonths As Byte
If PaymentType = 0 Then
DisplayMessage "You must select a payment type."
Cancel = True
Exit Sub
End If
bytMonths = YearsPaid * 13
Select Case PaymentType
Case 1, 2, 3, 4, 10, 12, 13, 14, 18, 22, 23
'If this is the first payment, set Paid Through from current date
If IsNull(PaidThrough) Or PaidThrough < Date Then
PaidThrough = DateSerial(Year(Date), Month(Date) + bytMonths, 1)
PaymentType = PaymentType
Else
'Otherwise, add additional months to the PaidThrough value.
PaidThrough = DateSerial(Year(PaidThrough), Month(PaidThrough) + _
bytMonths, 1)
PaymentType = PaymentType
End If
Case 5, 6, 7, 8, 9, 11, 15, 16, 17, 19, 20, 21, 24, 25, 26
Exit Sub
Case Else
End Select
Exit Sub
End Sub