Ok,
First, thank you for your help; the code looks great (from the LITTLE I know about VBA) and I think I understand how it works...
I have put the code you provided into a VBA module, with the changes/additions that ssanfu suggested. Now the code looks like this:
Code:
Function DoReview(ThursDate As Date, AdmitDate As Date) As Boolean
Dim SunBef As Date, SatAf As Date
Dim AdmitDay As Integer, Sun_Day As Integer, Sat_Day As Integer
SunBef = DateSerial(Year(ThursDate), Month(ThursDate), Day(ThursDate) - 4) 'Date of the preceding Sunday
SatAf = DateSerial(Year(ThursDate), Month(ThursDate), Day(ThursDate) + 2) 'Date of the subsequent Saturday
Sun_Day = Day(SunBef) 'Day of the month
Sat_Day = Day(SatAf)
AdmitDay = Day(AdmitDate)
DoReview = False
If Sun_Day < Sat_Day Then 'week contained in a single month
If AdmitDay >= Sun_Day And AdmitDay <= Sat_Day Then
DoReview = True
End If
Else 'week ending on next month
If AdmitDay >= Sun_Day Or AdmitDay <= Sat_Day Then
DoReview = True
End If
End If
End Function
I then added the expression to a simple query of "tblBeneficiaries" like so:
Code:
"SELECT {Last_Name, First_Name} WHERE DoReview ([Enter review date],[Admit_Date])"
When I run the query it does not prompt me for the review date parameter; instead the query returns this:
Query Returns.zip
I am a novice at this, so I'm probably placing the expression in the wrong place, or something just as obvious. Here is where I put the expression (in query design mode):
Query Design.zip
Please let me know what I can do to fix this. Thanks again!