(Gee, it's nice to have complete information without having to beg for it!)
Your SQL statement for Qry1 doesn't include ASNumber. It has to be included, or your subform will show all records for the given month and year, not just those with the same ASNumber as the main form.
I have a better picture of your application than I did in the earlier posts. There's a problem with having DateString on the main form. It only gets evaluated when the main form loads a record, not when Day is entered in the subform. Let's back up a bit.
Delete DateString from the main form. You don't need it (unless it's there for the user?). Instead, use the subform's BeforeUpdate procedure to set ServeDate. (This is exactly the sort of thing a form's BeforeUpdate is intended for.) The event procedure is:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error Goto ErrorHandler
Me!ServeDate = DateSerial(Forms!ASPData!Year, Forms!ASPData!Month, Me!Day)
ErrorExit:
Exit Sub
ErrorHandler:
Me!Day.SetFocus
Beep
MsgBox "Please enter a valid day for the month and year"
Cancel = True
Resume ErrorExit
End Sub
You said ServeDate is "hidden" in the query, but I'm not sure what you meant by that. In any case, you need a control on the subform for it; you can make it invisible.
Since only Free (and not Paid and Reduced) had the code, you had to update Free to make the ServeDate get updated. But since ServeDate is in your recordsource, you can just use a control bound to it to update it--much simpler. I didn't understand before that ServeDate was in your recordsource, or I wouldn't have suggested db.Execute to update it. Now that you have a bound control, get rid of the Free_AfterUpdate procedure.
One more thing: The subform's BeforeUpdate procedure has an error handler to trap the error that would occur if Month, Day, and Year can't be converted to a valid date (either one of them isn't numeric, or the day isn't valid for the month, e.g. April 31). If an error occurs, the update is canceled and the user is prompted to correct the Day. Year and Month must already be valid, or the subform wouldn't find any records to display, and Day couldn't have been entered. Rick Sprague