MCTampa
Board Regular
- Joined
- Apr 14, 2016
- Messages
- 97
In Table 1, I have an area number and a date.
In Table 2, I have an area number and a range of dates for which that area is restricted.
My issue is that in Table 2, the area can be restricted in multiple, non-consecutive ranges.
For example:
Table 1:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Area[/TD]
[TD]Dates[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]10/5/2019[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]9/27/2019[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]12/5/2019[/TD]
[/TR]
</tbody>[/TABLE]
Table 2:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Area[/TD]
[TD]Start[/TD]
[TD]End[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]8/1/2019[/TD]
[TD]9/31/2019[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]11/1/2019[/TD]
[TD]12/31/2019[/TD]
[/TR]
</tbody>[/TABLE]
Table 2 would indicate that area 330 is NOT restricted from 10/1/2019 through 10/31/2019.
However when I perform a LEFT JOIN through Area, I am not sure how to set up the query to take the date from Table 1 and evaluate whether it falls between either of the two restriction ranges on Table 2.
Ideally, I would like to indicate that 10/5/2019 is allowed and 9/27 and 12/5 are restricted.
I think this needs to be done with some sort of a loop in VBA, but I'm not sure where to begin.
Thanks for any help,
Mike
In Table 2, I have an area number and a range of dates for which that area is restricted.
My issue is that in Table 2, the area can be restricted in multiple, non-consecutive ranges.
For example:
Table 1:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Area[/TD]
[TD]Dates[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]10/5/2019[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]9/27/2019[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]12/5/2019[/TD]
[/TR]
</tbody>[/TABLE]
Table 2:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Area[/TD]
[TD]Start[/TD]
[TD]End[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]8/1/2019[/TD]
[TD]9/31/2019[/TD]
[/TR]
[TR]
[TD]330[/TD]
[TD]11/1/2019[/TD]
[TD]12/31/2019[/TD]
[/TR]
</tbody>[/TABLE]
Table 2 would indicate that area 330 is NOT restricted from 10/1/2019 through 10/31/2019.
However when I perform a LEFT JOIN through Area, I am not sure how to set up the query to take the date from Table 1 and evaluate whether it falls between either of the two restriction ranges on Table 2.
Ideally, I would like to indicate that 10/5/2019 is allowed and 9/27 and 12/5 are restricted.
I think this needs to be done with some sort of a loop in VBA, but I'm not sure where to begin.
Thanks for any help,
Mike