
Originally Posted by
alansidman
Thank you Alan!
I can see that at least I am already on the right track with the design of my small form. I have a text box in there; the format is set so that a DatePicker is triggered. I also have a query already created which I would like the form to run once the user chooses a date. I would like the date value entered through the DatePicker on the form to be used in the query.
Here is my problem: the query uses a user-defined VBA function called "DoReview" (which I didn't create) and the query itself doesn't make sense to me in the context of instructional videos and/or web-pages like the one you referred me to. Whenever I try to insert the full name of the text box from the form (Forms![frmStart_Schedule]![cboDatePick]) into the query as an argument in SQL view, or as a criteria in the query design view, I either get an error, or I continue to get the regular "Enter Parameter" dialogue box, even with frmStart_Schedule open in another tab.
Here is the VBA function code:
Code:
Function DoReview(ThursDate As Date, Admit_Date 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(Admit_Date)
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
And here is the Query:
Code:
PARAMETERS [Enter Review Date] DateTime;
SELECT tblLevel_Review.Beneficiary_Name, tblLevel_Review.Current_Level, tblLevel_Review.Review_Date
FROM tblLevel_Review
WHERE (((DoReview([Enter review date],[Review_Date]))<>False))
ORDER BY tblLevel_Review.Current_Level;
I've attached a relationship report Attachment 7772
Attachment 7772
I'm new at SQL and VBA language rules, so my learning curve is slow right now. I might be going about it all wrong...