Greetings. I am very new...which will be evident...to Access/VBA. I am building a database which has expiration dates. I want to place a flag ("^") next to a persons name when they are within 14 days of an expiration or if a yes/no box is checked. I want the flag if ONE of the 8 due dates or the yes/no box is not checked. The following is my poor attempt to automatically update while the information is put or changed into a form. This is just for the AllRead (yes/no) category. I need to incorporate the dates in this AfterUpdate to ensure they are accounted for if the AllRead is changed back to yes (no flag) but a date is within 14 days (a flag needed) then the flag stays.
Private Sub AllRead_AfterUpdate()
'updates Flag if AllRead is "No" or date expires is within 14 days of 'current date
Dim Daysa As Integer
Dim Days1a As Integer
Dim Days4a As Integer
Dim Days5a As Integer
Dim Days6a As Integer
Dim Days7a As Integer
Dim Days8a As Integer
Dim Days10a As Integer
'calculates days until due
Daysa = DateDiff("d", Now, Me.FlightPhysicalExpires)
Days1a = DateDiff("d", Now, Me.NATOPSFA18EFExpires)
Days4a = DateDiff("d", Now, Me.INSTCheckExpires)
Days5a = DateDiff("d", Now, Me.SwimPhysExpires)
Days6a = DateDiff("d", Now, Me.Seat_Brief_SJU5617Expires)
Days7a = DateDiff("d", Now, Me.NVGLabExpires)
Days8a = DateDiff("d", Now, Me.CRMFA18AFExpires)
Days10a = DateDiff("d", Now, Me.FirefightingExpires)
If AllRead = No Then
Dim Flag As String
Flag = Me.NameLookup + " ^"
Me.NewNameLookup = Flag
Else
Dim Flagged As String
Flagged = Me.NameLookup
Me.NewNameLookup = Flagged
If Daysa Or Days1a Or Days4a Or Days5a Or Days6a Or Days7a Or _Days8a Or Days10a <= 14 Then
Dim Flagging As String
Flagging = Me.NameLookup + " ^"
Me.NewNameLookup = Flagging
Else
End If
End If
Form.Refresh
End Sub
It will not remove the "^" when the 'No' box is checked to 'Yes'.
As I mentioned...I am self taught and new to this world. Any help is much appreciated...I am sure there are many holes in this. Happy Holidays.
.......................
Below is what I was originally using to update the expiration when input the date completed the initial training. This only accounts for that individual date though, and removes the "^" if the expiration is updated, but doesn't account for any other dates near expiration before removing the "^".
Private Sub NATOPSFA18EF_AfterUpdate()
'Computes NATOPS expiration dates
If IsMissing(Me.NATOPSFA18EF) Then
Me.NATOPSFA18EF = " "
End If
Me.NATOPSFA18EFExpires = DateSerial(Year(NATOPSFA18EF) + 1, Month(NATOPSFA18EF) + 1, 0)
'updates Flag if NATOPSFA18EFExpires is within 14 days of current date
Dim Days1 As Integer
Days1 = DateDiff("d", Now, Me.NATOPSFA18EFExpires)
If Days1 <= 14 Then
Dim Flag1 As String
Flag1 = Me.NameLookup + " ^"
Me.NewNameLookup = Flag1
Else
Me.NewNameLookup = Me.NameLookup
End If
Form.Refresh
End Sub
Private Sub AllRead_AfterUpdate()
'updates Flag if AllRead is "No" or date expires is within 14 days of 'current date
Dim Daysa As Integer
Dim Days1a As Integer
Dim Days4a As Integer
Dim Days5a As Integer
Dim Days6a As Integer
Dim Days7a As Integer
Dim Days8a As Integer
Dim Days10a As Integer
'calculates days until due
Daysa = DateDiff("d", Now, Me.FlightPhysicalExpires)
Days1a = DateDiff("d", Now, Me.NATOPSFA18EFExpires)
Days4a = DateDiff("d", Now, Me.INSTCheckExpires)
Days5a = DateDiff("d", Now, Me.SwimPhysExpires)
Days6a = DateDiff("d", Now, Me.Seat_Brief_SJU5617Expires)
Days7a = DateDiff("d", Now, Me.NVGLabExpires)
Days8a = DateDiff("d", Now, Me.CRMFA18AFExpires)
Days10a = DateDiff("d", Now, Me.FirefightingExpires)
If AllRead = No Then
Dim Flag As String
Flag = Me.NameLookup + " ^"
Me.NewNameLookup = Flag
Else
Dim Flagged As String
Flagged = Me.NameLookup
Me.NewNameLookup = Flagged
If Daysa Or Days1a Or Days4a Or Days5a Or Days6a Or Days7a Or _Days8a Or Days10a <= 14 Then
Dim Flagging As String
Flagging = Me.NameLookup + " ^"
Me.NewNameLookup = Flagging
Else
End If
End If
Form.Refresh
End Sub
It will not remove the "^" when the 'No' box is checked to 'Yes'.
As I mentioned...I am self taught and new to this world. Any help is much appreciated...I am sure there are many holes in this. Happy Holidays.
.......................
Below is what I was originally using to update the expiration when input the date completed the initial training. This only accounts for that individual date though, and removes the "^" if the expiration is updated, but doesn't account for any other dates near expiration before removing the "^".
Private Sub NATOPSFA18EF_AfterUpdate()
'Computes NATOPS expiration dates
If IsMissing(Me.NATOPSFA18EF) Then
Me.NATOPSFA18EF = " "
End If
Me.NATOPSFA18EFExpires = DateSerial(Year(NATOPSFA18EF) + 1, Month(NATOPSFA18EF) + 1, 0)
'updates Flag if NATOPSFA18EFExpires is within 14 days of current date
Dim Days1 As Integer
Days1 = DateDiff("d", Now, Me.NATOPSFA18EFExpires)
If Days1 <= 14 Then
Dim Flag1 As String
Flag1 = Me.NameLookup + " ^"
Me.NewNameLookup = Flag1
Else
Me.NewNameLookup = Me.NameLookup
End If
Form.Refresh
End Sub