IIF Statement using DateAdd?

  • Thread starter Thread starter bdmagnum
  • Start date Start date
B

bdmagnum

Hello to all,
I had posted a few questions earlier in the week and found the answers
As I said in my earlier post, I am working on a database dealing wit
306 Security Badges.

I have a TextBox "Check-In Date" that will input the current date whe
double clicked.

I have a pulldown ListBox "Status" with the choice of "STAFF" o
"STUDENT".

I also a blank TextBox "Expiration" that should present a future dat
based on "STAFF" (3 years from current date) and "STUDENT" (1 year fro
current date).

I have searched many hours for a possible solution and have come acros
DateAdd. I believe my situation also needs an IIF statement, but no
sure.

My question is as follows:

What code/formula should I use to achieve my goal and where do I pu
the code/formula(Control Source of "Expiration", After Update in one o
the three fields, in a query, etc.).

Thanks for responding,
Bil
 
Bill,

You are right that the DateAdd function is applicable here. I would be
inclined to use code on the AfterUpdate event of your Status combobox to
adjust the date in the Expiration textbox. It might look something like
this...

Private Sub Status_AfterUpdate()
Dim Interval As Integer
If IsNull(Me.Status) Then
Me.Expiration = Null
Else
Select Case Me.Status
Case "STAFF"
Interval = 3
Case "STUDENT"
Interval = 1
End Select
Me.Expiration = DateAdd("yyyy", Interval, Date)
End If

End Sub
 
Back
Top