Hi, I hope this is as clear as possible;
I have a multi tab form called 'Life Claims Form' that has a date on it called date of death from a table called 'Life Claim details'.
On a separate Tab on the same form I have a subform called 'Life Benefit Subform new' that has a field called 'Benefit Start Date' from a table called 'Life Benefits'.
The two tables both have a common field called 'Policy Number'. Within the 'Life Benefits' table it is possible to have multiple records per 'Policy Number' and therefore different 'Benefit Start date's.
I basically want to run an 'after update' query on the form that once the user has keyed a date in a field called 'Date of Death' it looks at all relevant records in the Life Benefits table and warns of any 'Benefit Start date's that are before the one the user has typed in.
I presume the vba should look through and check the table using a for each type command but I am at a loss how to do this.
Any help is greatly received.
For info I did get this to work for just checking one record as follows;
Many Thanks
Paul
I have a multi tab form called 'Life Claims Form' that has a date on it called date of death from a table called 'Life Claim details'.
On a separate Tab on the same form I have a subform called 'Life Benefit Subform new' that has a field called 'Benefit Start Date' from a table called 'Life Benefits'.
The two tables both have a common field called 'Policy Number'. Within the 'Life Benefits' table it is possible to have multiple records per 'Policy Number' and therefore different 'Benefit Start date's.
I basically want to run an 'after update' query on the form that once the user has keyed a date in a field called 'Date of Death' it looks at all relevant records in the Life Benefits table and warns of any 'Benefit Start date's that are before the one the user has typed in.
I presume the vba should look through and check the table using a for each type command but I am at a loss how to do this.
Any help is greatly received.
For info I did get this to work for just checking one record as follows;
Code:
[COLOR=black][FONT=Verdana]Private Sub Date_of_Death_AfterUpdate()
err1 = ""
err2 = ""[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If Date_of_Death.Value < Policy_Start_Date.Value Then
err1 = "Date of Death is before Policy start date."
End If[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If Date_of_Death.Value < [Forms]![Life Claims Form]![Life Benefit Subform new].[Form]![Benefit Start date].Value Then
err2 = "Date of Death is before Benefit start date."
End If[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If err1 <> "" Or err2 <> "" Then
MsgBox err1 & vbNewLine & err2, , "Warning"
End If[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]DoCmd.RunMacro "Life - Update calculated fields.Update year and age at death"[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End Sub[/FONT][/COLOR]
Many Thanks
Paul