I have a tab form (continuous form)that has the following code which checks the assignment end date and compares it to today's date. If the assignment end date is > than today's date the assigned percent field is updated. I can get the code to work, however, I want the code to trigger when tabbed form is selected. I tried a me.requery on the Form Active property but that does not work. Can anyone tell how I can trigger the code when the form is opened or selected? Or am I doing this the wrong way?
Code:
Option Compare Database
Option Explicit
Private Sub Assignment_Percent_Utilized_AfterUpdate()
Me.Requery
End Sub
Private Sub Form_Activate()
Me.Requery
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsDate(Me![Assignment Start Date]) Then
MsgBox "Invalid Start date"
Me![Assignment Start Date].SetFocus
Cancel = True
Exit Sub
End If
If Not IsNull(Me![Assignment End Date]) Then
If Not IsDate(Me![Assignment End Date]) Or Me![Assignment End Date] < Me![Assignment Start Date] Then
MsgBox "Invalid End Date - End Date Must Be Greater Than Start Date"
Me![Assignment End Date].SetFocus
Cancel = True
Exit Sub
End If
[COLOR=green]If [Assignment End Date] > Date Then
[Assignment Percent Utilized] = 0
Else
[Assignment Percent Utilized] = [Assignment Percent Utilized]
End If[/color]
End If