Hey, we're getting there at last
The first problem (MOH counting down by 1) will occur, I think, if the total
aProj(m+i) for the remaining months in the year is greater than aOnHand(m).
In other words, iRemaining never makes it to zero.
In this case, the code gets to the If m + i > 12 part, so we can easily
check for that condition and do something different. I suggest this:
If m + i > 12 Then
Done = True ' we can't go past 12
MOH = -1 ' invalid value
End If
Then, further down:
If MOH < 0 Then
Me("MOH" & Format(m, "00")) = Null
' or "n/a" or "-" if you prefer
Else
Me("MOH" & Format(m, "00")) = MOH
If MOH >= 0 Then
ShowRecord = True
End If
End If
For the filtering, declare two variables in the "Declarations Section" at
the top of your report module:
Private LowMOH as Single
Private HighMOH as Single
Now, in your Report_Open event procedure, load these values from the form:
With Forms("Name of your form")
LowMOH = !LowBOMOHChosen
HighMOH = !HighBOMOHChosen
End With
Then, in place of the dummy test If MOH >= 0, put in the real test for
values outside your bounds:
If MOH < LowMOH Or MOH > HighMOH Then
ShowRecord = True
End If
You might want to consider setting default values in Report_Open if the
textboxes on the form are empty.