G
Guest
I have a form with several date fields [EffectiveDate], [InitialTermExp],
[CurrentTermExp], and a combo box [cboRenewalConditions] that designates the
terms under which the agreement [AgName] referred to in the record renews. I
am trying to set up a complex AfterUpdate event so that when the user makes
certain choices under the combo box, the date [CurrentTermExp] automatically
fills in.
I tried to write a complex IIF function with a SWITCH function as the True
part, but Visual Basic is saying I have a "Compile Error" and need an
"Expression:=." Can someone tell me what's wrong with my code?
cboRenewalConditions_AfterUpdate
Iff(Not IsNull([EffectiveDate]) And Me![Expired/Terminated]=0,
SWITCH(Me![cboRenewalConditions]=1 And
DateSerial(Year(Now()),Month([EffectiveDate]),Day([EffectiveDate])<=Now()),
Me![CurrentTermExp] =
DateSerial(Year(Now())+1,Month([EffectiveDate]),Day([EffectiveDate]),
Me![cboRenewalConditions]=1 And
DateSerial(Year(Now()),Month([EffectiveDate]),Day([EffectiveDate])>Now(),
Me![CurrentTermExp]=DateSerial(Year(Now()),Month([EffectiveDate]),Day([EffectiveDate]),
Me![cboRenewalConditions]=2 And Not IsNull([InitialTermExp]),
Me![CurrentTermExp] = Me![InitialTermExp]), Me![CurrentTermExp]=Null))))
End If
[CurrentTermExp], and a combo box [cboRenewalConditions] that designates the
terms under which the agreement [AgName] referred to in the record renews. I
am trying to set up a complex AfterUpdate event so that when the user makes
certain choices under the combo box, the date [CurrentTermExp] automatically
fills in.
I tried to write a complex IIF function with a SWITCH function as the True
part, but Visual Basic is saying I have a "Compile Error" and need an
"Expression:=." Can someone tell me what's wrong with my code?
cboRenewalConditions_AfterUpdate
Iff(Not IsNull([EffectiveDate]) And Me![Expired/Terminated]=0,
SWITCH(Me![cboRenewalConditions]=1 And
DateSerial(Year(Now()),Month([EffectiveDate]),Day([EffectiveDate])<=Now()),
Me![CurrentTermExp] =
DateSerial(Year(Now())+1,Month([EffectiveDate]),Day([EffectiveDate]),
Me![cboRenewalConditions]=1 And
DateSerial(Year(Now()),Month([EffectiveDate]),Day([EffectiveDate])>Now(),
Me![CurrentTermExp]=DateSerial(Year(Now()),Month([EffectiveDate]),Day([EffectiveDate]),
Me![cboRenewalConditions]=2 And Not IsNull([InitialTermExp]),
Me![CurrentTermExp] = Me![InitialTermExp]), Me![CurrentTermExp]=Null))))
End If