Overview: I have two date fields - activity started, activity finished. I have three possible report options - current, future or not reporting. Future is by default ticked and there is no start or finish date; current and future are ticked if there is a start date but no finish date; current only is ticked if finished is within the last 31 days; no report is ticked if the finish date is older than 31 days. (Users can not enter a finish date without entering a start date.)
I have some code (below), which determines which boxes are ticked based on the data entered into two fields. Neither date field needs be updated, so putting the code on "after update" on either field doesn't necessarily ensure the code is run. At the moment I have a command button that the user clicks to update the output. I'd really prefer the code ran automatically.
Question 1: can I put a copy of the code on BOTH fields, so that if either one or the other (or both) are changed the code will run? Or will this cause me headaches?
Question 2: if I can't do 1, is there a suitable "after record update" option that I can attach the code to.
I have some code (below), which determines which boxes are ticked based on the data entered into two fields. Neither date field needs be updated, so putting the code on "after update" on either field doesn't necessarily ensure the code is run. At the moment I have a command button that the user clicks to update the output. I'd really prefer the code ran automatically.
Question 1: can I put a copy of the code on BOTH fields, so that if either one or the other (or both) are changed the code will run? Or will this cause me headaches?
Question 2: if I can't do 1, is there a suitable "after record update" option that I can attach the code to.
Code:
Private Sub Command54_Click()
If IsNull(Me.Started) And IsNull(Me.Closed) Then
Me.NoRpt = False
Me.CurrentRpt = False
Me.FutureRpt = True
Else
End If
If Not IsNull(Me.Started) And IsNull(Me.Closed) Then
Me.NoRpt = False
Me.CurrentRpt = True
Me.FutureRpt = True
Else
End If
If Not IsNull(Me.Started) And Closed >= Date - 31 Then
Me.NoRpt = False
Me.CurrentRpt = True
Me.FutureRpt = False
Else
End If
If Not IsNull(Me.Started) And Closed < Date - 31 Then
Me.NoRpt = True
Me.CurrentRpt = False
Me.FutureRpt = False
End If
End Sub