Hello all:
I'm having trouble with a nested If Statement working properly. I'm working in MS Access 2002 (OS Windows XP, ver 2002). The non-working code is going on the Form (a Single) as follows:
The code will fill in the last solution regardless of the date. I have, however, had it work if I use Me.Effective_Da te="1/1/10"
Given one choice ("equal to" only) be it a date or text and not a date range, the code works perfectly. I have also tried putting the dates in quotations within the range. It still does not work.
Alternatively, since there may be more than 2 or 3 date ranges in the future, I tried a Select Case as follows. It doesn't work either. It selects the first case only no matter what the Effective Date is.
Any help or tips would be appeciated, including whether an If/Then Statement or a Select Case solution would be more efficient. Thank you in advance.
LB in GA
I'm having trouble with a nested If Statement working properly. I'm working in MS Access 2002 (OS Windows XP, ver 2002). The non-working code is going on the Form (a Single) as follows:
Code:
Dim Effective_Date As Date
If Me.Effective_Date >= 1/1/10 And Me.Effective_Date <= 12/31/10 Then
[Prem/Ops Manual XS 1] = ([Prem/Ops U/L Manual 1] * 0.09)
[Prem/Ops Umbrella Prem 1] = [Prem/Ops Manual XS 1] * [Prem/Ops Umb Mod 1]
ElseIf Me.Effective_Date >= 1/1/11 And Me.Effective_Date <= 12/31/11 Then
[Prem/Ops Manual XS 1] = ([Prem/Ops U/L Manual 1] * 0.22)
[Prem/Ops Umbrella Prem 1] = [Prem/Ops Manual XS 1] * [Prem/Ops Umb Mod 1]
ElseIf Me.Effective_Date >= 1/1/12 And Me.Effective_Date <= 12/31/12 Then
[Prem/Ops Manual XS 1] = ([Prem/Ops U/L Manual 1] * 0.33)
[Prem/Ops Umbrella Prem 1] = [Prem/Ops Manual XS 1] * [Prem/Ops Umb Mod 1]
End If
Given one choice ("equal to" only) be it a date or text and not a date range, the code works perfectly. I have also tried putting the dates in quotations within the range. It still does not work.
Alternatively, since there may be more than 2 or 3 date ranges in the future, I tried a Select Case as follows. It doesn't work either. It selects the first case only no matter what the Effective Date is.
Code:
Dim Effective_Date As Date
Select Case [Effective Date]
Case Is >= 1 / 1 / 10, Is <= 12 / 31 / 10
[Prem/Ops Manual XS 1] = ([Prem/Ops U/L Manual 1] * 0.09)
[Prem/Ops Umbrella Prem 1] = [Prem/Ops Manual XS 1] * [Prem/Ops Umb Mod 1]
Case Is >= 1 / 1 / 11, Is <= 12 / 31 / 11
[Prem/Ops Manual XS 1] = ([Prem/Ops U/L Manual 1] * 0.22)
[Prem/Ops Umbrella Prem 1] = [Prem/Ops Manual XS 1] * [Prem/Ops Umb Mod 1]
End Select
LB in GA
Comment