A couple of suggestions for improving this function...
It would be nice if it threw up a warning if the year-end date was beyond the system date's year-end. It would reduce the risk of accidentally running the function way too early.
Also, the function does not act on the YTD 1099 Payments bucket or the Next Year 1099 bucket for those vendors not flagged to receive a 1099. I believe a vendor not flagged should be treated the same as a flagged vendor. Of course under normal circumstances the buckets would be zero to begin with, but in the case where the flag was originally turned on, and then turned off, there might be a non-zero figure, and it would be wrong to leave it there.
Steve