I have a subform with multiple bound fields, 3 of these bound fields are:
Code StartDate EndDate
I also have a table with a similar structure. This "check" table contains a code and the subsequent start and end dates for that code. There will be several instances of that code with different start and end dates throughout the year.
eg.
Code StartDate EndDate
ED1001 01/01/2006 10/01/2006
ED1001 05/03/2006 15/03/2006
ED2047 15/01/2006 19/01/2006
ED2047 11/08/2006 21/08/2006
etc.
A user enters a code, a start and an end date into the subform. At this point (afterupdate on EndDate) I need to check that the entered dates are within the dates for that code in the "check" table.
This requires reading the "check" table for all instances of the code and comparing the start and end date against those entered on the subform. If either or both of the subform dates lie outside of the "check" dates, then an error is flagged.
Several situations could occur.
1. The subform dates fall outside of all bracketed dates - an error
2. One of the dates will fall inside a bracket and one will be outside - an error
3. Both dates fall within (or equal to) a bracket of dates - no error
The mental logic here is simple. I am not an expert in VBA but I can visualise a cumbersome and complex solution, although I am not sure how to code at this point.
I would appreciate anyone providing me with a relatively simple solution or a direction to investigate.
Nigel.
Code StartDate EndDate
I also have a table with a similar structure. This "check" table contains a code and the subsequent start and end dates for that code. There will be several instances of that code with different start and end dates throughout the year.
eg.
Code StartDate EndDate
ED1001 01/01/2006 10/01/2006
ED1001 05/03/2006 15/03/2006
ED2047 15/01/2006 19/01/2006
ED2047 11/08/2006 21/08/2006
etc.
A user enters a code, a start and an end date into the subform. At this point (afterupdate on EndDate) I need to check that the entered dates are within the dates for that code in the "check" table.
This requires reading the "check" table for all instances of the code and comparing the start and end date against those entered on the subform. If either or both of the subform dates lie outside of the "check" dates, then an error is flagged.
Several situations could occur.
1. The subform dates fall outside of all bracketed dates - an error
2. One of the dates will fall inside a bracket and one will be outside - an error
3. Both dates fall within (or equal to) a bracket of dates - no error
The mental logic here is simple. I am not an expert in VBA but I can visualise a cumbersome and complex solution, although I am not sure how to code at this point.
I would appreciate anyone providing me with a relatively simple solution or a direction to investigate.
Nigel.