Hello. I'm using the sub from this thread https://answers.microsoft.com/en-us/msoffice/forum/all/can-you-use-a-public-function-sub-to-set-a/1043226e-ae37-450a-a045-3261256a9a29 to set a forms recordset. It works fine on the first form I set up. I couldn't get it to work with a second. After a LOT of pulling my hair out trying to figure out why it wouldn't work, I finally found the culprit. It seems like it doesn't like me sending dates to it via variable. I've tried all the combos below. For lines 820, the bottom 3 work perfectly. The top 3 don't return anything. I've tried the top 3 with the various lines 790 and 800. NONE work. Any advice why? (For testing purposes I just comment what I tried last, and uncomment what I'm trying this go around.)
Dim sLocation As String, sCO As String
Dim iEquipType As Integer, iExamFreq As Integer
Dim dExamDateStart As Date, dExamDateEnd As Date
Dim sExamDateStart As String, sExamDateEnd As String
'790 dExamDateStart = #5/1/2025#
'790 dExamDateStart = Format(#5/1/2025#, "mm/dd/yyyy")
790 sExamDateStart = "5/1/2025"
'800 dExamDateEnd = #5/23/2025#
'800 dExamDateEnd = Format(#5/23/2025#, "mm/dd/yyyy")
800 sExamDateEnd = "5/1/2025"
810 sCO = Nz(Me.Parent!txtCOFilter.Value, "")
'820 Call SetRecordset(Me, "qryRecentExams_Primary", "parEquipmentLocation", sLocation, "parEquipmentTypeID", iEquipType, "parExamFrequencyID", iExamFreq, "parExamDateStart", dExamDateStart, "parExamDateEnd", dExamDateStart, "parCO#", sCO)
'820 Call SetRecordset(Me, "qryRecentExams_Primary", "parEquipmentLocation", sLocation, "parEquipmentTypeID", iEquipType, "parExamFrequencyID", iExamFreq, "parExamDateStart", Format(dExamDateStart, "mm/dd/yyyy"), "parExamDateEnd", Format(dExamDateStart, "mm/dd/yyyy"), "parCO#", sCO)
820 Call SetRecordset(Me, "qryRecentExams_Primary", "parEquipmentLocation", sLocation, "parEquipmentTypeID", iEquipType, "parExamFrequencyID", iExamFreq, "parExamDateStart", Format(sExamDateStart, "mm/dd/yyyy"), "parExamDateEnd", Format(sExamDateStart, "mm/dd/yyyy"), "parCO#", sCO)
'820 Call SetRecordset(Me, "qryRecentExams_Primary", "parEquipmentLocation", "", "parEquipmentTypeID", 0, "parExamFrequencyID", 0, "parExamDateStart", #5/1/2025#, "parExamDateEnd", #5/23/2025#, "parCO#", "")
'820 Call SetRecordset(Me, "qryRecentExams_Primary", "parEquipmentLocation", "", "parEquipmentTypeID", 0, "parExamFrequencyID", 0, "parExamDateStart", Format(#5/1/2025#, "mm/dd/yyyy"), "parExamDateEnd", Format(#5/23/2025#, "mm/dd/yyyy"), "parCO#", "")
'820 Call SetRecordset(Me, "qryRecentExams_Primary", "parEquipmentLocation", sLocation, "parEquipmentTypeID", iEquipType, "parExamFrequencyID", iExamFreq, "parExamDateStart", #5/1/2025#, "parExamDateEnd", #5/23/2025#, "parCO#", sCO)